#### [Abblix\.Oidc\.Server](https://www.abblix.com/docs/api/abblix-oidc-server 'index')
### [Abblix\.Oidc\.Server\.Features\.MultiTenancy](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy 'Abblix\.Oidc\.Server\.Features\.MultiTenancy')

## ITenantManager Interface

Creates, changes and removes the tenants a store holds while the server runs, refusing a change the server's
startup checks would refuse, so a tenant is never stored in a form the server would leave out\.

```csharp
public interface ITenantManager
```

Derived  
↳ [TenantManager](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.TenantManager 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantManager')

### Remarks
Each change is judged against the tenants the store holds then and written through the store's
[ITenantStoreWriter](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantStoreWriter 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantStoreWriter')\. This instance then reads the store again to serve it at once; should that
reading fail, or a created tenant not be readied to be served, it serves the change from its next reading that
succeeds, and other instances serve it at their next reading\. A change written is reported as made either way\.

The changes of one instance are made one at a time. Two instances changing tenants at once may each pass the
checks and together leave the store holding two tenants the checks refuse, such as two at one address: the
readings then leave both out and log why, as for any tenant the store holds that the checks refuse.
### Methods

## ITenantManager\.CreateAsync\(TenantDefinition, CancellationToken\) Method {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.CreateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,System.Threading.CancellationToken)}

Creates [tenant](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.CreateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,System.Threading.CancellationToken).tenant 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantManager\.CreateAsync\(Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition, System\.Threading\.CancellationToken\)\.tenant') under a new generation, so nothing kept for an earlier tenant of its id
carries over to it\.

```csharp
System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant,Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal>> CreateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition tenant, System.Threading.CancellationToken cancellationToken);
```
#### Parameters

###### `tenant` [TenantDefinition](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition') {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.CreateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,System.Threading.CancellationToken).tenant}

The tenant to create; its generation is assigned here\.

###### `cancellationToken` [System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken') {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.CreateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,System.Threading.CancellationToken).cancellationToken}

Cancels the change until it is written; after that it only stops the wait for
            this instance to serve the change, which is then reported as made\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[Abblix\.Utils\.Result&lt;](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[StoredTenant](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.StoredTenant')[,](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[TenantChangeRefusal](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantChangeRefusal')[&gt;](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
The tenant as stored, or why it was refused\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
The store registers no [ITenantStoreWriter](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantStoreWriter 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantStoreWriter')\.

## ITenantManager\.RemoveAsync\(string, string, CancellationToken\) Method {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.RemoveAsync(string,string,System.Threading.CancellationToken)}

Removes the tenant stored under [tenantId](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.RemoveAsync(string,string,System.Threading.CancellationToken).tenantId 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantManager\.RemoveAsync\(string, string, System\.Threading\.CancellationToken\)\.tenantId'), while it is stored at
[version](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.RemoveAsync(string,string,System.Threading.CancellationToken).version 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantManager\.RemoveAsync\(string, string, System\.Threading\.CancellationToken\)\.version')\.

```csharp
System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant,Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal>> RemoveAsync(string tenantId, string version, System.Threading.CancellationToken cancellationToken);
```
#### Parameters

###### `tenantId` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.RemoveAsync(string,string,System.Threading.CancellationToken).tenantId}

The id of the tenant to remove\.

###### `version` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.RemoveAsync(string,string,System.Threading.CancellationToken).version}

The version the tenant was read at\.

###### `cancellationToken` [System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken') {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.RemoveAsync(string,string,System.Threading.CancellationToken).cancellationToken}

Cancels the change until it is written; after that it only stops the wait for
            this instance to serve the change, which is then reported as made\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[Abblix\.Utils\.Result&lt;](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[StoredTenant](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.StoredTenant')[,](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[TenantChangeRefusal](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantChangeRefusal')[&gt;](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
The tenant as it was stored, or why the removal was refused\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
The store registers no [ITenantStoreWriter](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantStoreWriter 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantStoreWriter')\.

## ITenantManager\.UpdateAsync\(TenantDefinition, string, CancellationToken\) Method {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.UpdateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken)}

Replaces the tenant stored under the id of [tenant](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.UpdateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken).tenant 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantManager\.UpdateAsync\(Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition, string, System\.Threading\.CancellationToken\)\.tenant'), keeping its generation, while it is
stored at [version](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.UpdateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken).version 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantManager\.UpdateAsync\(Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition, string, System\.Threading\.CancellationToken\)\.version')\.

```csharp
System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant,Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal>> UpdateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition tenant, string version, System.Threading.CancellationToken cancellationToken);
```
#### Parameters

###### `tenant` [TenantDefinition](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantDefinition') {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.UpdateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken).tenant}

The tenant as it is to be; a generation it names is not taken, the stored one is kept\.

###### `version` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.UpdateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken).version}

The version the tenant was read at\.

###### `cancellationToken` [System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken') {#Abblix.Oidc.Server.Features.MultiTenancy.ITenantManager.UpdateAsync(Abblix.Oidc.Server.Features.MultiTenancy.TenantDefinition,string,System.Threading.CancellationToken).cancellationToken}

Cancels the change until it is written; after that it only stops the wait for
            this instance to serve the change, which is then reported as made\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[Abblix\.Utils\.Result&lt;](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[StoredTenant](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.StoredTenant 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.StoredTenant')[,](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[TenantChangeRefusal](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.TenantChangeRefusal 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.TenantChangeRefusal')[&gt;](https://www.abblix.com/docs/api/abblix-utils/Abblix.Utils.Result_TSuccess_TFailure_ 'Abblix\.Utils\.Result\`2')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
The tenant as stored, or why it was refused\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
The store registers no [ITenantStoreWriter](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.MultiTenancy.ITenantStoreWriter 'Abblix\.Oidc\.Server\.Features\.MultiTenancy\.ITenantStoreWriter')\.
