Table of Contents

Class ResourcePath

Namespace
FoundationaLLM.Common.Models.ResourceProviders
Assembly
FoundationaLLM.Common.dll

Provides the logic for handling FoundationaLLM resource identifiers.

public class ResourcePath
Inheritance
ResourcePath
Inherited Members
Extension Methods

Constructors

ResourcePath(string, ImmutableList<string>, Dictionary<string, ResourceTypeDescriptor>, bool)

Creates a new resource identifier from a resource path optionally allowing an action.

public ResourcePath(string resourcePath, ImmutableList<string> allowedResourceProviders, Dictionary<string, ResourceTypeDescriptor> allowedResourceTypes, bool allowAction = true)

Parameters

resourcePath string

The resource path used to create the resource identifier.

allowedResourceProviders ImmutableList<string>

Provides a list of allowed resource providers.

allowedResourceTypes Dictionary<string, ResourceTypeDescriptor>

Provides a dictionary of ResourceTypeDescriptor used to validate resource types.

allowAction bool

Optional parameter that indicates whether an action name is allowed as part of the resource identifier.

Properties

Action

Gets the action (if any) specified in the resource path.

public string? Action { get; }

Property Value

string

HasAction

Indicates whether the resource path contains a valid action or not.

public bool HasAction { get; }

Property Value

bool

HasResourceId

Indicates whether the resource path contains a valid resource id or not.

public bool HasResourceId { get; }

Property Value

bool

HasSubordinateResourceId

A flag denoting if the resource path contains subordinate resources or not.

public bool HasSubordinateResourceId { get; }

Property Value

bool

InstanceId

The instance id of the resource identifier. Can be null if the resource path does not contain an instance id.

public string? InstanceId { get; }

Property Value

string

IsInstancePath

Indicates whether the resource path is an instance path or not (i.e., only contains the FoundationaLLM instance identifier).

public bool IsInstancePath { get; }

Property Value

bool

IsResourceTypePath

Indicates whether the resource path refers to a resource type (does not contain a resource name).

public bool IsResourceTypePath { get; }

Property Value

bool

IsRootPath

Indicates whether the resource path is a root path ("/") or not.

public bool IsRootPath { get; }

Property Value

bool

MainResourceId

Gets the resource id of the main resource type of the path.

public string? MainResourceId { get; }

Property Value

string

MainResourceType

Gets the object type of the main resource type of the path.

public Type? MainResourceType { get; }

Property Value

Type

Remarks

The main resource type is the first resource type in the path. In the case of nested resources, this will be the resource type of the main resource.

MainResourceTypeName

Gets the name of the main resource type of the path.

public string? MainResourceTypeName { get; }

Property Value

string

Remarks

The main resource type is the first resource type in the path. In the case of nested resources, this will be the resource type of the main resource.

ObjectId

Gets the resource object identifier associated with the resource path.

public string? ObjectId { get; }

Property Value

string

Remarks

Only fully qualified resource paths can be converted to object identifiers.

RawResourcePath

Gets the raw resource path which was used to create the resource path object.

public string RawResourcePath { get; }

Property Value

string

ResourceId

Gets the resource id of the resource identified by the path.

public string? ResourceId { get; }

Property Value

string

Remarks

This is the last resource id in the path. If the path refers to nested resources, this will be the resource id of the last resource. Otherwise, it will be the resource id of the main resource (and hence identical to MainResourceId).

ResourceProvider

The resource provider of the resource identifier. Can be null if the resource path does not contain a resource provider.

public string? ResourceProvider { get; }

Property Value

string

ResourceType

Gets the resource type of the resource identified by the path.

public Type? ResourceType { get; }

Property Value

Type

Remarks

This is the last resource type in the path. If the path refers to nested resources, this will be the resource type of the last resource. Otherwise, it will be the resource type of the main resource (and hence identical to MainResourceType).

ResourceTypeInstances

The resource type instances of the resource identifier.

public List<ResourceTypeInstance> ResourceTypeInstances { get; }

Property Value

List<ResourceTypeInstance>

ResourceTypeName

Gets the resource type name of the resource identified by the path.

public string? ResourceTypeName { get; }

Property Value

string

Remarks

This is the last resource type name in the path. If the path refers to nested resources, this will be the resource type name of the last resource. Otherwise, it will be the resource type name of the main resource (and hence identical to MainResourceTypeName).

Methods

GetAllowedResourceTypes(string)

Retrieves the allowed resource types for a specified resource provider.

public static Dictionary<string, ResourceTypeDescriptor> GetAllowedResourceTypes(string resourceProvider)

Parameters

resourceProvider string

The name of the resource provider.

Returns

Dictionary<string, ResourceTypeDescriptor>

GetObjectId(string?, string?)

Computes the object id of the resource identifier.

public string GetObjectId(string? instanceId, string? resourceProvider)

Parameters

instanceId string

The FoundationaLLM instance id. Provide this if the resource does not have a fully-qualified resource identifier.

resourceProvider string

The name of the resource provider. Provide this if the resource does not have a fully-qualified resource identifier.

Returns

string

The object id.

GetObjectId(string, string, string, string)

Computes the object id of the resource identifier.

public static string GetObjectId(string instanceId, string resourceProviderName, string resourceTypeName, string resourceName)

Parameters

instanceId string

The FoundationaLLM instance id.

resourceProviderName string

The name of the resource provider.

resourceTypeName string

The name of the resource type.

resourceName string

The name of the resource.

Returns

string

The object id.

GetObjectId(string, string, string, string, string, string)

Computes the object id of the resource identifier.

public static string GetObjectId(string instanceId, string resourceProviderName, string mainResourceTypeName, string mainResourceName, string resourceTypeName, string resourceName)

Parameters

instanceId string

The FoundationaLLM instance id.

resourceProviderName string

The name of the resource provider.

mainResourceTypeName string

The name of the main resource type.

mainResourceName string

The name of the main resource.

resourceTypeName string

The name of the resource type.

resourceName string

The name of the resource.

Returns

string

The object id.

GetResourcePath(string)

Parses a resource path.

public static ResourcePath GetResourcePath(string resourcePath)

Parameters

resourcePath string

The resource path to be parsed.

Returns

ResourcePath

A ResourcePath object containing the parsed resource path.

GetResourceTypeObjectId()

Computes the object id of the resource type associated with the resource identifier.

public string GetResourceTypeObjectId()

Returns

string

The resource type object id.

Exceptions

ResourceProviderException

IncludesResourcePath(ResourcePath, bool)

Determines whether the resource path includes another specified resource path.

public bool IncludesResourcePath(ResourcePath other, bool allowEqual = true)

Parameters

other ResourcePath

The ResourcePath to check for inclusion.

allowEqual bool

Indicates whether an equal resource path is considered to be included or not.

Returns

bool

True if the specified resource path is included in the resource path.

MatchesResourceTypes(ResourcePath)

Determines whether the resource path matches exactly (including order) the resource types of another specified resource path.

public bool MatchesResourceTypes(ResourcePath other)

Parameters

other ResourcePath

The ResourcePath to be matched.

Returns

bool

True if the resource path matches exactly (including order) the resource types of the other resource path.

TryParse(string, ImmutableList<string>, Dictionary<string, ResourceTypeDescriptor>, bool, out ResourcePath?)

Tries to parse a resource path and create a resource identifier from it.

public static bool TryParse(string resourcePath, ImmutableList<string> allowedResourceProviders, Dictionary<string, ResourceTypeDescriptor> allowedResourceTypes, bool allowAction, out ResourcePath? resourcePathInstance)

Parameters

resourcePath string

The resource path used to create the resource identifier.

allowedResourceProviders ImmutableList<string>

Provides a list of allowed resource providers.

allowedResourceTypes Dictionary<string, ResourceTypeDescriptor>

Provides a dictionary of ResourceTypeDescriptor used to validate resource types.

allowAction bool

Optional parameter that indicates whether an action name is allowed as part of the resource identifier.

resourcePathInstance ResourcePath

The parsed resource path.

Returns

bool

True if the resource path is parsed successfully.

TryParseInstanceId(string, out string?)

Tries to retrieve the identifier of the FoundationaLLM instance from a resource path.

public static bool TryParseInstanceId(string resourcePath, out string? instanceId)

Parameters

resourcePath string

The resource path to analyze.

instanceId string

The FoundationaLLM instance identifier.

Returns

bool

True if a valid intance identifier is retrieved successfully.

TryParseResourceProvider(string, out string?)

Tries to retrieve the name of the resource provider from a resource path.

public static bool TryParseResourceProvider(string resourcePath, out string? resourceProvider)

Parameters

resourcePath string

The resource path to analyze.

resourceProvider string

The resource provider name.

Returns

bool

True if a valid resource provider name is retrieved successfully.