Table of Contents

Class ResourceProviderServiceBase<TResourceReference>

Namespace
FoundationaLLM.Common.Services.ResourceProviders
Assembly
FoundationaLLM.Common.dll

Implements basic resource provider functionality

public class ResourceProviderServiceBase<TResourceReference> : IResourceProviderService, IManagementProviderService where TResourceReference : ResourceReference

Type Parameters

TResourceReference

The type of the resource reference used by the resource provider.

Inheritance
ResourceProviderServiceBase<TResourceReference>
Implements
Derived
Inherited Members
Extension Methods

Constructors

ResourceProviderServiceBase(InstanceSettings, ResourceProviderCacheSettings, IAuthorizationServiceClient, IStorageService, IEventService, IResourceValidatorFactory, IServiceProvider, ILogger, List<string>?, bool)

Creates a new instance of the resource provider.

public ResourceProviderServiceBase(InstanceSettings instanceSettings, ResourceProviderCacheSettings cacheSettings, IAuthorizationServiceClient authorizationServiceClient, IStorageService storageService, IEventService eventService, IResourceValidatorFactory resourceValidatorFactory, IServiceProvider serviceProvider, ILogger logger, List<string>? eventTypesToSubscribe = null, bool useInternalReferencesStore = false)

Parameters

instanceSettings InstanceSettings

The InstanceSettings that provides instance-wide settings.

cacheSettings ResourceProviderCacheSettings

The ResourceProviderCacheSettings that provides settings for the resource provider cache.

authorizationServiceClient IAuthorizationServiceClient

The IAuthorizationServiceClient providing authorization services to the resource provider.

storageService IStorageService

The IStorageService providing storage services to the resource provider.

eventService IEventService

The IEventService providing event services to the resource provider.

resourceValidatorFactory IResourceValidatorFactory

The IResourceValidatorFactory providing services to instantiate resource validators.

serviceProvider IServiceProvider

The IServiceProvider of the main dependency injection container.

logger ILogger

The logger used for logging.

eventTypesToSubscribe List<string>

The list of Event Service event namespaces to subscribe to for local event processing.

useInternalReferencesStore bool

Indicates whether the resource provider should use the internal resource references store or provide one of its own.

Fields

_authorizationServiceClient

The IAuthorizationServiceClient providing authorization services to the resource provider.

protected readonly IAuthorizationServiceClient _authorizationServiceClient

Field Value

IAuthorizationServiceClient

_eventService

The IEventService providing event services to the resource provider.

protected readonly IEventService _eventService

Field Value

IEventService

_instanceSettings

The InstanceSettings that provides instance-wide settings.

protected readonly InstanceSettings _instanceSettings

Field Value

InstanceSettings

_logger

The logger used for logging.

protected readonly ILogger _logger

Field Value

ILogger

_resourceReferenceStore

The resource reference store used by the resource provider.

protected ResourceProviderResourceReferenceStore<TResourceReference>? _resourceReferenceStore

Field Value

ResourceProviderResourceReferenceStore<TResourceReference>

_resourceValidatorFactory

The IResourceValidatorFactory providing services to instantiate resource validators.

protected readonly IResourceValidatorFactory _resourceValidatorFactory

Field Value

IResourceValidatorFactory

_serviceProvider

The IServiceProvider tha provides dependency injection services.

protected readonly IServiceProvider _serviceProvider

Field Value

IServiceProvider

_storageService

The IStorageService providing storage services to the resource provider.

protected readonly IStorageService _storageService

Field Value

IStorageService

Properties

AllowedResourceTypes

The metadata describing the resource types allowed by the resource provider.

public Dictionary<string, ResourceTypeDescriptor> AllowedResourceTypes { get; }

Property Value

Dictionary<string, ResourceTypeDescriptor>

IsInitialized

Indicates whether the resource provider is initialized or not.

public bool IsInitialized { get; }

Property Value

bool

Name

The name of the resource provider.

public string Name { get; }

Property Value

string

StorageAccountName

The name of the storage account used by the resource provider.

public string StorageAccountName { get; }

Property Value

string

StorageContainerName

The name of the storage account container used by the resource provider.

public string StorageContainerName { get; }

Property Value

string

_name

The name of the resource provider. Must be overridden in derived classes.

protected virtual string _name { get; }

Property Value

string

_serializerSettings

Default JSON serialization settings.

protected virtual JsonSerializerOptions _serializerSettings { get; }

Property Value

JsonSerializerOptions

_storageContainerName

The name of the storage container name used by the resource provider to store its internal data.

protected virtual string _storageContainerName { get; }

Property Value

string

Methods

CheckResourceName<T>(ResourceName)

Checks if a resource name is available.

protected Task<ResourceNameCheckResult> CheckResourceName<T>(ResourceName resourceName)

Parameters

resourceName ResourceName

The ResourceName providing the name to be checked for availability.

Returns

Task<ResourceNameCheckResult>

A ResourceNameCheckResult indicating the outcome of the operation.

Type Parameters

T

The type of resource for which the name check is performed.

CreateResource(TResourceReference, Stream, string?)

Creates a resource based on a resource reference and the resource itself.

protected Task CreateResource(TResourceReference resourceReference, Stream content, string? contentType)

Parameters

resourceReference TResourceReference

The resource reference used to identify the resource.

content Stream

The resource itself.

contentType string

The resource content type, if applicable.

Returns

Task

Exceptions

ResourceProviderException

CreateResource<T>(TResourceReference, T)

Creates a resource based on a resource reference and the resource itself.

protected Task CreateResource<T>(TResourceReference resourceReference, T resource) where T : ResourceBase

Parameters

resourceReference TResourceReference

The resource reference used to identify the resource.

resource T

The resource itself.

Returns

Task

Type Parameters

T

The type of resource to create.

Exceptions

ResourceProviderException

CreateResources<T1, T2>(TResourceReference, T1, TResourceReference, T2)

Creates two resources based on their resource references and the resources themselves.

protected Task CreateResources<T1, T2>(TResourceReference resourceReference1, T1 resource1, TResourceReference resourceReference2, T2 resource2) where T1 : ResourceBase where T2 : ResourceBase

Parameters

resourceReference1 TResourceReference

The resource reference used to identify the first resource.

resource1 T1

The first resource to create.

resourceReference2 TResourceReference

The resource reference used to identify the second resource.

resource2 T2

The second resource to create.

Returns

Task

Type Parameters

T1

The type of the first resource to create.

T2

The type of the second resource to create.

Exceptions

ResourceProviderException

DeleteResourceAsync(ResourcePath, UnifiedUserIdentity)

The internal implementation of DeleteResourceAsync. Must be overridden in derived classes.

protected virtual Task DeleteResourceAsync(ResourcePath resourcePath, UnifiedUserIdentity userIdentity)

Parameters

resourcePath ResourcePath

A ResourcePath containing information about the resource path.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

Returns

Task

DeleteResourceAsyncInternal<T>(ResourcePath, ResourcePathAuthorizationResult, UnifiedUserIdentity)

The internal implementation of DeleteResourceAsync. Must be overridden in derived classes.

protected virtual Task DeleteResourceAsyncInternal<T>(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult, UnifiedUserIdentity userIdentity) where T : ResourceBase

Parameters

resourcePath ResourcePath

The ResourcePath containing information about the resource path.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing information about the calling user identity.

Returns

Task

Type Parameters

T

The type of the resource being deleted.

Exceptions

NotImplementedException

DeleteResourceAsync<T>(string, string, UnifiedUserIdentity)

Deletes logically a resource based on its logical path.

public Task DeleteResourceAsync<T>(string instanceId, string resourceName, UnifiedUserIdentity userIdentity) where T : ResourceBase

Parameters

instanceId string

The FoundationaLLM instance identifier.

resourceName string

The name of the resource being logically deleted.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing information about the calling user identity.

Returns

Task

Type Parameters

T

The type of the resource.

DeleteResource<T>(ResourcePath)

Deletes a resource.

protected Task DeleteResource<T>(ResourcePath resourcePath)

Parameters

resourcePath ResourcePath

The ResourcePath identifying the resource to delete.

Returns

Task

Type Parameters

T

The type of resource to delete.

Remarks

The operation is a logical delete. The resource reference is marked deleted, but the resource content remains in storage. To fully remove a resource, the delete operation must be followed by a purge operation.

Exceptions

ResourceProviderException

EnsureAndValidatePolicyDefinitions(ResourcePath, ResourcePathAuthorizationResult)

public PolicyDefinition EnsureAndValidatePolicyDefinitions(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult)

Parameters

resourcePath ResourcePath
authorizationResult ResourcePathAuthorizationResult

Returns

PolicyDefinition

ExecuteActionAsync(ResourcePath, ResourcePathAuthorizationResult, string, UnifiedUserIdentity)

The internal implementation of ExecuteActionAsync. Must be overriden in derived classes.

protected virtual Task<object> ExecuteActionAsync(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult, string serializedAction, UnifiedUserIdentity userIdentity)

Parameters

resourcePath ResourcePath

A ResourcePath containing information about the resource path.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

serializedAction string

The serialized details of the action being executed.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

Returns

Task<object>

Remarks

In the special case of the filter action, the override must handle the authorization result and return the appropriate response as follows:

  1. The read action is authorized for the resource path itself. In this case, all matching resources must be returned according to the PBAC policies specified by the authorization result (if any).
  2. The read action is denied for the resource path itself. In this case, only the matching resources specified in the subordinate authorized resource paths list of the authorization result should be returned (if any).

ExecuteResourceActionAsyncInternal<T, TAction, TResult>(ResourcePath, ResourcePathAuthorizationResult, TAction, UnifiedUserIdentity)

The internal implementation of ExecuteResourceActionAsync. Must be overridden in derived classes.

protected virtual Task<TResult> ExecuteResourceActionAsyncInternal<T, TAction, TResult>(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult, TAction actionPayload, UnifiedUserIdentity userIdentity) where T : ResourceBase where TAction : class? where TResult : ResourceProviderActionResult

Parameters

resourcePath ResourcePath

A ResourcePath containing information about the resource path.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

actionPayload TAction

The TAction object containing details about the action to be executed.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

Returns

Task<TResult>

A TResult object with the result of the action.

Type Parameters

T
TAction
TResult

Remarks

In the special case of the filter action, the override must handle the authorization result and return the appropriate response as follows:

  1. The read action is authorized for the resource path itself. In this case, all matching resources must be returned according to the PBAC policies specified by the authorization result (if any).
  2. The read action is denied for the resource path itself. In this case, only the matching resources specified in the subordinate authorized resource paths list of the authorization result should be returned (if any).

ExecuteResourceActionAsync<T, TAction, TResult>(string, string, string, TAction, UnifiedUserIdentity)

Executes an action on a resource.

public Task<TResult> ExecuteResourceActionAsync<T, TAction, TResult>(string instanceId, string resourceName, string actionName, TAction actionPayload, UnifiedUserIdentity userIdentity) where T : ResourceBase where TAction : class? where TResult : ResourceProviderActionResult

Parameters

instanceId string

The FoundationaLLM instance identifier.

resourceName string

The name of the resource on which the action is executed.

actionName string

The name of the action being executed.

actionPayload TAction

The payload of the action providing details about it.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

Returns

Task<TResult>

Type Parameters

T

The type of the resource.

TAction

The type of the action payload providing details about the action to be executed.

TResult

The type of the result returned.

FilterResources<T>(ResourcePath, ResourceFilter, ResourcePathAuthorizationResult, ResourceProviderGetOptions?, Func<TResourceReference, bool, Task<T>>?, Func<T, bool>?)

Loads a list of resources filtered based on object IDs.

protected Task<IEnumerable<T>> FilterResources<T>(ResourcePath resourcePath, ResourceFilter filter, ResourcePathAuthorizationResult authorizationResult, ResourceProviderGetOptions? options = null, Func<TResourceReference, bool, Task<T>>? customResourceLoader = null, Func<T, bool>? customResourceFilter = null) where T : ResourceBase

Parameters

resourcePath ResourcePath

The ResourcePath resource type path to filter.

filter ResourceFilter

The ResourceFilter used to filter the resources.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

options ResourceProviderGetOptions

The ResourceProviderGetOptions which provides operation parameters.

customResourceLoader Func<TResourceReference, bool, Task<T>>

An optional function that loads the resource used to override the default resource loading mechanism.

customResourceFilter Func<T, bool>

An optional function that filters the list of loaded resources.

Returns

Task<IEnumerable<T>>

A list of objects of type T.

Type Parameters

T

The type of resources to load.

GetParsedResourcePath(string, bool)

Gets a ResourcePath object for the specified string resource path.

protected ResourcePath GetParsedResourcePath(string resourcePath, bool allowAction = true)

Parameters

resourcePath string

The resource path.

allowAction bool

Indicates whether actions are allowed in the resource path.

Returns

ResourcePath

A ResourcePath object.

GetResourceAsyncInternal<T>(ResourcePath, ResourcePathAuthorizationResult, UnifiedUserIdentity, ResourceProviderGetOptions?)

The internal implementation of GetResource. Must be overridden in derived classes.

protected virtual Task<T> GetResourceAsyncInternal<T>(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult, UnifiedUserIdentity userIdentity, ResourceProviderGetOptions? options = null) where T : ResourceBase

Parameters

resourcePath ResourcePath

A ResourcePath containing information about the resource path.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing information about the calling user identity.

options ResourceProviderGetOptions

The ResourceProviderGetOptions which provides operation parameters.

Returns

Task<T>

Type Parameters

T

GetResourceAsync<T>(string, UnifiedUserIdentity, ResourceProviderGetOptions?)

Gets a resource based on its logical path.

public Task<T> GetResourceAsync<T>(string resourcePath, UnifiedUserIdentity userIdentity, ResourceProviderGetOptions? options = null) where T : ResourceBase

Parameters

resourcePath string

The logical path of the resource.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

options ResourceProviderGetOptions

The ResourceProviderGetOptions which provides operation parameters.

Returns

Task<T>

The instance of the resource corresponding to the specified logical path.

Type Parameters

T

The type of the resource.

GetResourceAsync<T>(string, string, UnifiedUserIdentity, ResourceProviderGetOptions?)

Gets a resource based on its name.

public Task<T> GetResourceAsync<T>(string instanceId, string resourceName, UnifiedUserIdentity userIdentity, ResourceProviderGetOptions? options = null) where T : ResourceBase

Parameters

instanceId string

The FoundationaLLM instance identifier.

resourceName string

The logical path of the resource.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

options ResourceProviderGetOptions

The ResourceProviderGetOptions which provides operation parameters.

Returns

Task<T>

The instance of the resource corresponding to the specified logical path.

Type Parameters

T

The type of the resource.

GetResourcePath(string, Type, string?, string?)

Get the fully qualified resource path for a specified resource.

protected (string ResourcePath, ResourceTypeDescriptor ResourceTypeDescriptor) GetResourcePath(string instanceId, Type resourceType, string? resourceName = null, string? actionName = null)

Parameters

instanceId string

The FoundationaLLM instance identifier.

resourceType Type

The type of the resource.

resourceName string

The name of the resource.

actionName string

The name of the action.

Returns

(string ResourcePath, ResourceTypeDescriptor ResourceTypeDescriptor)

GetResourceProviderServiceByName(string)

Gets a resource provider service by name.

protected IResourceProviderService GetResourceProviderServiceByName(string name)

Parameters

name string

The name of the resource provider.

Returns

IResourceProviderService

The IResourceProviderService used to interact with the resource provider.

GetResourceTypes()

Gets the details about the resource types managed by the resource provider.

protected virtual Dictionary<string, ResourceTypeDescriptor> GetResourceTypes()

Returns

Dictionary<string, ResourceTypeDescriptor>

A dictionary of ResourceTypeDescriptor objects with details about the resource types.

GetResourcesAsync(ResourcePath, ResourcePathAuthorizationResult, UnifiedUserIdentity, ResourceProviderGetOptions?)

The internal implementation of GetResourcesAsync. Must be overridden in derived classes.

protected virtual Task<object> GetResourcesAsync(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult, UnifiedUserIdentity userIdentity, ResourceProviderGetOptions? options = null)

Parameters

resourcePath ResourcePath

A ResourcePath containing information about the resource path.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

options ResourceProviderGetOptions

The ResourceProviderGetOptions which provides operation parameters.

Returns

Task<object>

Remarks

The override implementation should return a list of resources or a single resource, depending on the resource path. It also must handle the authorization result and return the appropriate response as follows:

  1. The resource path refers to a single resource. In this case, the authorization is already confirmed and the specific resource should be returned.
  2. The resource path refers to a resource type and the read action is authorized for the resource path itself. In this case, all resources must be returned according to the PBAC policies specified by the authorization result (if any).
  3. The resource path refers to a resource type and the read action is denied for the resource path itself. In this case, only the resources specified in the subordinate authorized resource paths list of the authorization result should be returned (if any).

GetResourcesAsync<T>(string, UnifiedUserIdentity, ResourceProviderGetOptions?)

Gets resources of a specific type.

public Task<List<ResourceProviderGetResult<T>>> GetResourcesAsync<T>(string instanceId, UnifiedUserIdentity userIdentity, ResourceProviderGetOptions? options = null) where T : ResourceBase

Parameters

instanceId string

The FoundationaLLM instance identifier.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

options ResourceProviderGetOptions

The ResourceProviderGetOptions which provides operation parameters.

Returns

Task<List<ResourceProviderGetResult<T>>>

A list of ResourceProviderGetResult<T> containing the loaded resources.

Type Parameters

T

The type of resource to return.

HandleCacheResetCommand()

Handles the cache reset command.

public virtual Task HandleCacheResetCommand()

Returns

Task

HandleDeleteAsync(string, UnifiedUserIdentity)

Handles a HTTP DELETE request for a specified resource path.

public Task HandleDeleteAsync(string resourcePath, UnifiedUserIdentity userIdentity)

Parameters

resourcePath string

The resource path.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

Returns

Task

HandleEventsInternal(EventTypeEventArgs)

Handles events received from the IEventService when they are dequeued locally.

protected virtual Task HandleEventsInternal(EventTypeEventArgs e)

Parameters

e EventTypeEventArgs

The EventTypeEventArgs containing the event type and the actual events.

Returns

Task

HandleGetAsync(string, UnifiedUserIdentity, ResourceProviderGetOptions?)

Handles a HTTP GET request for a specified resource path.

public Task<object> HandleGetAsync(string resourcePath, UnifiedUserIdentity userIdentity, ResourceProviderGetOptions? options = null)

Parameters

resourcePath string

The resource path.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

options ResourceProviderGetOptions

The ResourceProviderGetOptions which provides operation parameters.

Returns

Task<object>

The serialized form of the result of handling the request.

HandlePostAsync(string, string?, ResourceProviderFormFile?, UnifiedUserIdentity)

Handles a HTTP POST request for a specified resource path.

public Task<object> HandlePostAsync(string resourcePath, string? serializedResource, ResourceProviderFormFile? formFile, UnifiedUserIdentity userIdentity)

Parameters

resourcePath string

The resource path.

serializedResource string
formFile ResourceProviderFormFile

The optional file attached to the request.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

Returns

Task<object>

The serialized form of the result of handling the request.

Initialize()

Initializes the resource provider.

public Task Initialize()

Returns

Task

InitializeInternal()

The internal implementation of Initialize. Must be overridden in derived classes.

protected virtual Task InitializeInternal()

Returns

Task

LoadResource<T>(string)

Loads a resource based on its name.

protected Task<T?> LoadResource<T>(string resourceName) where T : ResourceBase

Parameters

resourceName string

The name of the resource.

Returns

Task<T>

The loaded resource.

Type Parameters

T

The type of resource to load.

Exceptions

ResourceProviderException

LoadResource<T>(TResourceReference)

Loads a resource based on its resource reference.

protected Task<T?> LoadResource<T>(TResourceReference resourceReference) where T : ResourceBase

Parameters

resourceReference TResourceReference

The type of resource reference used to indetify the resource to load.

Returns

Task<T>

The loaded resource.

Type Parameters

T

The type of resource to load.

Remarks

Always ensure this method is called within a lock to avoid unexpected racing conditions.

Exceptions

ResourceProviderException

LoadResources<T>(ResourceTypeInstance, ResourcePathAuthorizationResult, ResourceProviderGetOptions?, Func<TResourceReference, bool, Task<T>>?)

Loads one or more resources of a specific type.

protected Task<List<ResourceProviderGetResult<T>>> LoadResources<T>(ResourceTypeInstance instance, ResourcePathAuthorizationResult authorizationResult, ResourceProviderGetOptions? options = null, Func<TResourceReference, bool, Task<T>>? customResourceLoader = null) where T : ResourceBase

Parameters

instance ResourceTypeInstance

The ResourceTypeInstance that indicates a specific resource to load.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

options ResourceProviderGetOptions

The ResourceProviderGetOptions which provides operation parameters.

customResourceLoader Func<TResourceReference, bool, Task<T>>

An optional function that loads the resource used to override the default resource loading mechanism.

Returns

Task<List<ResourceProviderGetResult<T>>>

A list of ResourceProviderGetResult<T> objects.

Type Parameters

T

The type of resources to load.

PurgeResource<T>(ResourcePath)

Purges a deleted resource.

protected Task<ResourceProviderActionResult> PurgeResource<T>(ResourcePath resourcePath)

Parameters

resourcePath ResourcePath

The ResourcePath identifying the resource to purge.

Returns

Task<ResourceProviderActionResult>

A ResourceProviderActionResult indicating the outcome of the operation.

Type Parameters

T

The type of the resource to purge.

Remarks

The operation can only be applied to a resource that has been logically deleted.

Exceptions

ResourceProviderException

ResourceExistsAsyncInternal<T>(ResourcePath, ResourcePathAuthorizationResult, UnifiedUserIdentity)

The internal implementation of ResourceExistsAsync. Must be overridden in derived classes.

protected virtual Task<(bool Exists, bool Deleted)> ResourceExistsAsyncInternal<T>(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult, UnifiedUserIdentity userIdentity) where T : ResourceBase

Parameters

resourcePath ResourcePath

The ResourcePath containing information about the resource path.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing information about the calling user identity.

Returns

Task<(bool Exists, bool Deleted)>

A tuple indicating whether the resource exists or not and whether it is logically deleted or not.

Type Parameters

T

The type of resource being checked.

Remarks

If a resource was logically deleted but not purged, this method will return True, indicating the existence of the resource.

ResourceExistsAsync<T>(string, string, UnifiedUserIdentity)

Checks if a resource exists.

public Task<(bool Exists, bool Deleted)> ResourceExistsAsync<T>(string instanceId, string resourceName, UnifiedUserIdentity userIdentity) where T : ResourceBase

Parameters

instanceId string

The FoundationaLLM instance identifier.

resourceName string

The resource name being checked.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing information about the calling user identity.

Returns

Task<(bool Exists, bool Deleted)>

A tuple indicating whether the resource exists or not and whether it is logically deleted or not.

Type Parameters

T

The type of the resource.

Remarks

If a resource was logically deleted but not purged, this method will return True, indicating the existence of the resource.

SaveResource<T>(TResourceReference, T)

Saves a resource based on its resource reference and the resource itself.

protected Task SaveResource<T>(TResourceReference resourceReference, T resource) where T : ResourceBase

Parameters

resourceReference TResourceReference

The resource reference used to identify the resource.

resource T

The resource to be saved.

Returns

Task

Type Parameters

T

The type of resource to save.

SendResourceProviderEvent(string, object?)

Sends a resource provider event to the event service.

protected Task SendResourceProviderEvent(string eventType, object? data = null)

Parameters

eventType string

The type of the event to send.

data object

The optional data to send with the event.

Returns

Task

Remarks

See EventTypes for a list of event types.

SetDefaultResource<T>(ResourcePath)

Sets a resource as the default for its resource type.

protected Task<ResourceProviderActionResult> SetDefaultResource<T>(ResourcePath resourcePath)

Parameters

resourcePath ResourcePath

The ResourcePath identifying the resource to which the default resource name should be set.

Returns

Task<ResourceProviderActionResult>

A ResourceProviderActionResult indicating the outcome of the operation.

Type Parameters

T

The resource type.

Exceptions

ResourceProviderException

UpdateBaseProperties(ResourceBase, UnifiedUserIdentity, bool)

Updates the base properties of an object derived from ResourceBase.

protected void UpdateBaseProperties(ResourceBase resource, UnifiedUserIdentity userIdentity, bool isNew = false)

Parameters

resource ResourceBase

The ResourceBase object to be updated.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing the information about the identity of the user that performed a create or update operation on the resource.

isNew bool

Indicates whether the resource is new or being updated.

UpdateResourcePropertiesAsyncInternal<T, TResult>(ResourcePath, ResourcePathAuthorizationResult, Dictionary<string, object>, UnifiedUserIdentity)

The internal implementation of UpdateResourcePropertiesAsync. Must be overridden in derived classes.

protected virtual Task<TResult> UpdateResourcePropertiesAsyncInternal<T, TResult>(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult, Dictionary<string, object> propertyValues, UnifiedUserIdentity userIdentity) where T : ResourceBase where TResult : ResourceProviderUpsertResult<T>

Parameters

resourcePath ResourcePath

The ResourcePath containing information about the resource path.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

propertyValues Dictionary<string, object>

The dictionary with propery names and values to update.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing information about the calling user identity.

Returns

Task<TResult>

Type Parameters

T

The type of the resource being updated.

TResult

The type of the result returned.

UpdateResourcePropertiesAsync<T, TResult>(string, string, Dictionary<string, object?>, UnifiedUserIdentity)

Updates a subset of the properties of a resource.

public Task<TResult> UpdateResourcePropertiesAsync<T, TResult>(string instanceId, string resourceName, Dictionary<string, object?> propertyValues, UnifiedUserIdentity userIdentity) where T : ResourceBase where TResult : ResourceProviderUpsertResult<T>

Parameters

instanceId string

The FoundationaLLM instance identifier.

resourceName string

The name of the resource being updated.

propertyValues Dictionary<string, object>

The dictionary with propery names and values to update.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

Returns

Task<TResult>

Type Parameters

T

The type of the resource.

TResult

The type of the result returned.

UpsertResourceAsync(ResourcePath, string?, ResourceProviderFormFile?, UnifiedUserIdentity)

The internal implementation of UpsertResourceAsync. Must be overridden in derived classes.

protected virtual Task<object> UpsertResourceAsync(ResourcePath resourcePath, string? serializedResource, ResourceProviderFormFile? formFile, UnifiedUserIdentity userIdentity)

Parameters

resourcePath ResourcePath

A ResourcePath containing information about the resource path.

serializedResource string

The optional serialized resource being created or updated.

formFile ResourceProviderFormFile

The optional file attached to the request.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

Returns

Task<object>

UpsertResourceAsyncInternal<T, TResult>(ResourcePath, ResourcePathAuthorizationResult, T, UnifiedUserIdentity, ResourceProviderUpsertOptions?)

The internal implementation of UpsertResourceAsync. Must be overridden in derived classes.

protected virtual Task<TResult> UpsertResourceAsyncInternal<T, TResult>(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult, T resource, UnifiedUserIdentity userIdentity, ResourceProviderUpsertOptions? options = null) where T : ResourceBase where TResult : ResourceProviderUpsertResult<T>

Parameters

resourcePath ResourcePath

A ResourcePath containing information about the resource path.

authorizationResult ResourcePathAuthorizationResult

The ResourcePathAuthorizationResult containing the result of the resource path authorization request.

resource T

The instance of the resource being created or updated.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing information about the calling user identity.

options ResourceProviderUpsertOptions

The ResourceProviderUpsertOptions which provides operation parameters.

Returns

Task<TResult>

Type Parameters

T

The type of the resource being created or updated.

TResult

The type of the result returned.

UpsertResourceAsync<T, TResult>(string, T, UnifiedUserIdentity, ResourceProviderUpsertOptions?)

Creates or updates a resource based on its logical path.

public Task<TResult> UpsertResourceAsync<T, TResult>(string instanceId, T resource, UnifiedUserIdentity userIdentity, ResourceProviderUpsertOptions? options = null) where T : ResourceBase where TResult : ResourceProviderUpsertResult<T>

Parameters

instanceId string

The FoundationaLLM instance identifier.

resource T

The instance of the resource being created or updated.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity with details about the identity of the user.

options ResourceProviderUpsertOptions

The ResourceProviderUpsertOptions which provides operation parameters.

Returns

Task<TResult>

The object id of the resource.

Type Parameters

T

The type of the resource.

TResult

The type of the result returned

WaitForInitialization()

Waits for the resource provider service to be initialized.

public Task WaitForInitialization()

Returns

Task