ConfidentialLedgerClient.CreateOrUpdateLedgerUser Method

Definition

[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 CreateOrUpdateLedgerUser(string userId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrUpdateLedgerUser : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.CreateOrUpdateLedgerUser : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function CreateOrUpdateLedgerUser (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 CreateOrUpdateLedgerUser and parse the result.

TokenCredential credential = new DefaultAzureCredential();
ConfidentialLedgerClient client = new ConfidentialLedgerClient(new Uri("http://localhost:3000"), credential);

using RequestContent content = RequestContent.Create(new
{
    assignedRoles = new object[]
    {
        "Administrator"
    },
});
Response response = client.CreateOrUpdateLedgerUser("<userId>", content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("assignedRoles")[0].ToString());

This sample shows how to call CreateOrUpdateLedgerUser 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
{
    assignedRoles = new object[]
    {
        "Administrator"
    },
});
Response response = client.CreateOrUpdateLedgerUser("<userId>", content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("assignedRoles")[0].ToString());
Console.WriteLine(result.GetProperty("userId").ToString());

Applies to