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
InstanceSettingsThe InstanceSettings that provides instance-wide settings.
cacheSettings
ResourceProviderCacheSettingsThe ResourceProviderCacheSettings that provides settings for the resource provider cache.
authorizationServiceClient
IAuthorizationServiceClientThe IAuthorizationServiceClient providing authorization services to the resource provider.
storageService
IStorageServiceThe IStorageService providing storage services to the resource provider.
eventService
IEventServiceThe IEventService providing event services to the resource provider.
resourceValidatorFactory
IResourceValidatorFactoryThe IResourceValidatorFactory providing services to instantiate resource validators.
serviceProvider
IServiceProviderThe IServiceProvider of the main dependency injection container.
logger
ILoggerThe logger used for logging.
eventTypesToSubscribe
List<string>The list of Event Service event namespaces to subscribe to for local event processing.
useInternalReferencesStore
boolIndicates 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
_eventService
The IEventService providing event services to the resource provider.
protected readonly IEventService _eventService
Field Value
_instanceSettings
The InstanceSettings that provides instance-wide settings.
protected readonly InstanceSettings _instanceSettings
Field Value
_logger
The logger used for logging.
protected readonly ILogger _logger
Field Value
_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
_serviceProvider
The IServiceProvider tha provides dependency injection services.
protected readonly IServiceProvider _serviceProvider
Field Value
_storageService
The IStorageService providing storage services to the resource provider.
protected readonly IStorageService _storageService
Field Value
Properties
AllowedResourceTypes
The metadata describing the resource types allowed by the resource provider.
public Dictionary<string, ResourceTypeDescriptor> AllowedResourceTypes { get; }
Property Value
IsInitialized
Indicates whether the resource provider is initialized or not.
public bool IsInitialized { get; }
Property Value
Name
The name of the resource provider.
public string Name { get; }
Property Value
StorageAccountName
The name of the storage account used by the resource provider.
public string StorageAccountName { get; }
Property Value
StorageContainerName
The name of the storage account container used by the resource provider.
public string StorageContainerName { get; }
Property Value
_name
The name of the resource provider. Must be overridden in derived classes.
protected virtual string _name { get; }
Property Value
_serializerSettings
Default JSON serialization settings.
protected virtual JsonSerializerOptions _serializerSettings { get; }
Property Value
_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
Methods
CheckResourceName<T>(ResourceName)
Checks if a resource name is available.
protected Task<ResourceNameCheckResult> CheckResourceName<T>(ResourceName resourceName)
Parameters
resourceName
ResourceNameThe 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
TResourceReferenceThe resource reference used to identify the resource.
content
StreamThe resource itself.
contentType
stringThe resource content type, if applicable.
Returns
Exceptions
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
TResourceReferenceThe resource reference used to identify the resource.
resource
TThe resource itself.
Returns
Type Parameters
T
The type of resource to create.
Exceptions
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
TResourceReferenceThe resource reference used to identify the first resource.
resource1
T1The first resource to create.
resourceReference2
TResourceReferenceThe resource reference used to identify the second resource.
resource2
T2The second resource to create.
Returns
Type Parameters
T1
The type of the first resource to create.
T2
The type of the second resource to create.
Exceptions
DeleteResourceAsync(ResourcePath, UnifiedUserIdentity)
The internal implementation of DeleteResourceAsync. Must be overridden in derived classes.
protected virtual Task DeleteResourceAsync(ResourcePath resourcePath, UnifiedUserIdentity userIdentity)
Parameters
resourcePath
ResourcePathA ResourcePath containing information about the resource path.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
Returns
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
ResourcePathThe ResourcePath containing information about the resource path.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity providing information about the calling user identity.
Returns
Type Parameters
T
The type of the resource being deleted.
Exceptions
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
stringThe FoundationaLLM instance identifier.
resourceName
stringThe name of the resource being logically deleted.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity providing information about the calling user identity.
Returns
Type Parameters
T
The type of the resource.
DeleteResource<T>(ResourcePath)
Deletes a resource.
protected Task DeleteResource<T>(ResourcePath resourcePath)
Parameters
resourcePath
ResourcePathThe ResourcePath identifying the resource to delete.
Returns
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
EnsureAndValidatePolicyDefinitions(ResourcePath, ResourcePathAuthorizationResult)
public PolicyDefinition EnsureAndValidatePolicyDefinitions(ResourcePath resourcePath, ResourcePathAuthorizationResult authorizationResult)
Parameters
resourcePath
ResourcePathauthorizationResult
ResourcePathAuthorizationResult
Returns
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
ResourcePathA ResourcePath containing information about the resource path.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
serializedAction
stringThe serialized details of the action being executed.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
Returns
Remarks
In the special case of the filter
action, the override must handle the authorization result and return
the appropriate response as follows:
- 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).
- 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
ResourcePathA ResourcePath containing information about the resource path.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
actionPayload
TActionThe
TAction
object containing details about the action to be executed.userIdentity
UnifiedUserIdentityThe 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:
- 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).
- 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
stringThe FoundationaLLM instance identifier.
resourceName
stringThe name of the resource on which the action is executed.
actionName
stringThe name of the action being executed.
actionPayload
TActionThe payload of the action providing details about it.
userIdentity
UnifiedUserIdentityThe 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
ResourcePathThe ResourcePath resource type path to filter.
filter
ResourceFilterThe ResourceFilter used to filter the resources.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
options
ResourceProviderGetOptionsThe 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
stringThe resource path.
allowAction
boolIndicates 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
ResourcePathA ResourcePath containing information about the resource path.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity providing information about the calling user identity.
options
ResourceProviderGetOptionsThe 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
stringThe logical path of the resource.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
options
ResourceProviderGetOptionsThe 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
stringThe FoundationaLLM instance identifier.
resourceName
stringThe logical path of the resource.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
options
ResourceProviderGetOptionsThe 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
stringThe FoundationaLLM instance identifier.
resourceType
TypeThe type of the resource.
resourceName
stringThe name of the resource.
actionName
stringThe name of the action.
Returns
GetResourceProviderServiceByName(string)
Gets a resource provider service by name.
protected IResourceProviderService GetResourceProviderServiceByName(string name)
Parameters
name
stringThe 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
ResourcePathA ResourcePath containing information about the resource path.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
options
ResourceProviderGetOptionsThe ResourceProviderGetOptions which provides operation parameters.
Returns
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:
- The resource path refers to a single resource. In this case, the authorization is already confirmed and the specific resource should be returned.
- 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).
- 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
stringThe FoundationaLLM instance identifier.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
options
ResourceProviderGetOptionsThe 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
HandleDeleteAsync(string, UnifiedUserIdentity)
Handles a HTTP DELETE request for a specified resource path.
public Task HandleDeleteAsync(string resourcePath, UnifiedUserIdentity userIdentity)
Parameters
resourcePath
stringThe resource path.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
Returns
HandleEventsInternal(EventTypeEventArgs)
Handles events received from the IEventService when they are dequeued locally.
protected virtual Task HandleEventsInternal(EventTypeEventArgs e)
Parameters
e
EventTypeEventArgsThe EventTypeEventArgs containing the event type and the actual events.
Returns
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
stringThe resource path.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
options
ResourceProviderGetOptionsThe ResourceProviderGetOptions which provides operation parameters.
Returns
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
stringThe resource path.
serializedResource
stringformFile
ResourceProviderFormFileThe optional file attached to the request.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
Returns
Initialize()
Initializes the resource provider.
public Task Initialize()
Returns
InitializeInternal()
The internal implementation of Initialize. Must be overridden in derived classes.
protected virtual Task InitializeInternal()
Returns
LoadResource<T>(string)
Loads a resource based on its name.
protected Task<T?> LoadResource<T>(string resourceName) where T : ResourceBase
Parameters
resourceName
stringThe name of the resource.
Returns
- Task<T>
The loaded resource.
Type Parameters
T
The type of resource to load.
Exceptions
LoadResource<T>(TResourceReference)
Loads a resource based on its resource reference.
protected Task<T?> LoadResource<T>(TResourceReference resourceReference) where T : ResourceBase
Parameters
resourceReference
TResourceReferenceThe 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
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
ResourceTypeInstanceThe ResourceTypeInstance that indicates a specific resource to load.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
options
ResourceProviderGetOptionsThe 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
ResourcePathThe 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
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
ResourcePathThe ResourcePath containing information about the resource path.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
userIdentity
UnifiedUserIdentityThe 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
stringThe FoundationaLLM instance identifier.
resourceName
stringThe resource name being checked.
userIdentity
UnifiedUserIdentityThe 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
TResourceReferenceThe resource reference used to identify the resource.
resource
TThe resource to be saved.
Returns
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
stringThe type of the event to send.
data
objectThe optional data to send with the event.
Returns
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
ResourcePathThe 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
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
ResourceBaseThe ResourceBase object to be updated.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity providing the information about the identity of the user that performed a create or update operation on the resource.
isNew
boolIndicates 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
ResourcePathThe ResourcePath containing information about the resource path.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
propertyValues
Dictionary<string, object>The dictionary with propery names and values to update.
userIdentity
UnifiedUserIdentityThe 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
stringThe FoundationaLLM instance identifier.
resourceName
stringThe name of the resource being updated.
propertyValues
Dictionary<string, object>The dictionary with propery names and values to update.
userIdentity
UnifiedUserIdentityThe 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
ResourcePathA ResourcePath containing information about the resource path.
serializedResource
stringThe optional serialized resource being created or updated.
formFile
ResourceProviderFormFileThe optional file attached to the request.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
Returns
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
ResourcePathA ResourcePath containing information about the resource path.
authorizationResult
ResourcePathAuthorizationResultThe ResourcePathAuthorizationResult containing the result of the resource path authorization request.
resource
TThe instance of the resource being created or updated.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity providing information about the calling user identity.
options
ResourceProviderUpsertOptionsThe 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
stringThe FoundationaLLM instance identifier.
resource
TThe instance of the resource being created or updated.
userIdentity
UnifiedUserIdentityThe UnifiedUserIdentity with details about the identity of the user.
options
ResourceProviderUpsertOptionsThe 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()