ConfidentialLedgerClient.CreateOrUpdateUser Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
[Protocol Method] Adds a user or updates a user's fields.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual Azure.Response CreateOrUpdateUser (string userId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrUpdateUser : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.CreateOrUpdateUser : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function CreateOrUpdateUser (userId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response
Parameters
- userId
- String
The user id, either an AAD object ID or certificate fingerprint.
- content
- RequestContent
The content to send as the body of the request.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
userId
or content
is null.
Service returned a non-success status code.
Examples
This sample shows how to call CreateOrUpdateUser and parse the result.
TokenCredential credential = new DefaultAzureCredential();
ConfidentialLedgerClient client = new ConfidentialLedgerClient(new Uri("http://localhost:3000"), credential);
using RequestContent content = RequestContent.Create(new
{
assignedRole = "Administrator",
});
Response response = client.CreateOrUpdateUser("<userId>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("assignedRole").ToString());
This sample shows how to call CreateOrUpdateUser with all parameters and request content and parse the result.
TokenCredential credential = new DefaultAzureCredential();
ConfidentialLedgerClient client = new ConfidentialLedgerClient(new Uri("http://localhost:3000"), credential);
using RequestContent content = RequestContent.Create(new
{
assignedRole = "Administrator",
});
Response response = client.CreateOrUpdateUser("<userId>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("assignedRole").ToString());
Console.WriteLine(result.GetProperty("userId").ToString());
Remarks
A JSON merge patch is applied for existing users
Below is the JSON schema for the request and response payloads.
Request Body:
Schema for LedgerUser
:
{
assignedRole: "Administrator" | "Contributor" | "Reader", # Required. Represents an assignable role.
userId: string, # Optional. Identifier for the user. This must either be an AAD object id or a certificate fingerprint.
}
Response Body:
Schema for LedgerUser
:
{
assignedRole: "Administrator" | "Contributor" | "Reader", # Required. Represents an assignable role.
userId: string, # Optional. Identifier for the user. This must either be an AAD object id or a certificate fingerprint.
}
Applies to
Azure SDK for .NET