diff --git a/reference.md b/reference.md index e1acc9f9d..36a538000 100644 --- a/reference.md +++ b/reference.md @@ -977,6 +977,125 @@ await client.Clients.CreateAsync(new CreateClientRequestContent { Name = "name" + + + + +
client.Clients.PreviewCimdMetadataAsync(PreviewCimdMetadataRequestContent { ... }) -> WithRawResponseTask<PreviewCimdMetadataResponseContent> +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ + + Fetches and validates a Client ID Metadata Document without creating a client. + Returns the raw metadata and how it would be mapped to Auth0 client fields. + This endpoint is useful for testing metadata URIs before creating CIMD clients. + +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.Clients.PreviewCimdMetadataAsync( + new PreviewCimdMetadataRequestContent { ExternalClientId = "external_client_id" } +); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**request:** `PreviewCimdMetadataRequestContent` + +
+
+
+
+ + +
+
+
+ +
client.Clients.RegisterCimdClientAsync(RegisterCimdClientRequestContent { ... }) -> WithRawResponseTask<RegisterCimdClientResponseContent> +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ + + Idempotent registration for Client ID Metadata Document (CIMD) clients. + Uses external_client_id as the unique identifier for upsert operations. + **Create:** Returns 201 when a new client is created (requires \ +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.Clients.RegisterCimdClientAsync( + new RegisterCimdClientRequestContent { ExternalClientId = "external_client_id" } +); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**request:** `RegisterCimdClientRequestContent` + +
+
+
+
+ +
@@ -2149,6 +2268,101 @@ await client.CustomDomains.CreateAsync( + + + + +
client.CustomDomains.GetDefaultAsync() -> WithRawResponseTask<GetDefaultDomainResponseContent> +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Retrieve the tenant's default domain. +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.CustomDomains.GetDefaultAsync(); +``` +
+
+
+
+ + +
+
+
+ +
client.CustomDomains.SetDefaultAsync(SetDefaultCustomDomainRequestContent { ... }) -> WithRawResponseTask<UpdateDefaultDomainResponseContent> +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Set the default custom domain for the tenant. +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.CustomDomains.SetDefaultAsync( + new SetDefaultCustomDomainRequestContent { Domain = "domain" } +); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**request:** `SetDefaultCustomDomainRequestContent` + +
+
+
+
+ +
@@ -5895,6 +6109,70 @@ await client.Prompts.UpdateSettingsAsync(new UpdateSettingsRequestContent()); ## RefreshTokens +
client.RefreshTokens.ListAsync(GetRefreshTokensRequestParameters { ... }) -> Pager<RefreshTokenResponseContent> +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Retrieve a paginated list of refresh tokens for a specific user, with optional filtering by client ID. Results are sorted by credential_id ascending. +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.RefreshTokens.ListAsync( + new GetRefreshTokensRequestParameters + { + UserId = "user_id", + ClientId = "client_id", + From = "from", + Take = 1, + Fields = "fields", + IncludeFields = true, + } +); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**request:** `GetRefreshTokensRequestParameters` + +
+
+
+
+ + +
+
+
+
client.RefreshTokens.GetAsync(id) -> WithRawResponseTask<GetRefreshTokenResponseContent>
@@ -18161,6 +18439,271 @@ await client.Organizations.ClientGrants.DeleteAsync("id", "grant_id");
+ + +
+ +## Organizations Connections +
client.Organizations.Connections.ListAsync(id, ListOrganizationAllConnectionsRequestParameters { ... }) -> Pager<OrganizationAllConnectionPost> +
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.Organizations.Connections.ListAsync( + "id", + new ListOrganizationAllConnectionsRequestParameters + { + Page = 1, + PerPage = 1, + IncludeTotals = true, + IsEnabled = true, + } +); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**id:** `string` β€” Organization identifier. + +
+
+ +
+
+ +**request:** `ListOrganizationAllConnectionsRequestParameters` + +
+
+
+
+ + +
+
+
+ +
client.Organizations.Connections.CreateAsync(id, CreateOrganizationAllConnectionRequestParameters { ... }) -> WithRawResponseTask<CreateOrganizationAllConnectionResponseContent> +
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.Organizations.Connections.CreateAsync( + "id", + new CreateOrganizationAllConnectionRequestParameters { ConnectionId = "connection_id" } +); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**id:** `string` β€” Organization identifier. + +
+
+ +
+
+ +**request:** `CreateOrganizationAllConnectionRequestParameters` + +
+
+
+
+ + +
+
+
+ +
client.Organizations.Connections.GetAsync(id, connectionId) -> WithRawResponseTask<GetOrganizationAllConnectionResponseContent> +
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.Organizations.Connections.GetAsync("id", "connection_id"); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**id:** `string` β€” Organization identifier. + +
+
+ +
+
+ +**connectionId:** `string` β€” Connection identifier. + +
+
+
+
+ + +
+
+
+ +
client.Organizations.Connections.DeleteAsync(id, connectionId) +
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.Organizations.Connections.DeleteAsync("id", "connection_id"); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**id:** `string` β€” Organization identifier. + +
+
+ +
+
+ +**connectionId:** `string` β€” Connection identifier. + +
+
+
+
+ + +
+
+
+ +
client.Organizations.Connections.UpdateAsync(id, connectionId, UpdateOrganizationConnectionRequestParameters { ... }) -> WithRawResponseTask<UpdateOrganizationAllConnectionResponseContent> +
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```csharp +await client.Organizations.Connections.UpdateAsync( + "id", + "connection_id", + new UpdateOrganizationConnectionRequestParameters() +); +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**id:** `string` β€” Organization identifier. + +
+
+ +
+
+ +**connectionId:** `string` β€” Connection identifier. + +
+
+ +
+
+ +**request:** `UpdateOrganizationConnectionRequestParameters` + +
+
+
+
+ +
diff --git a/src/Auth0.ManagementApi/Auth0.ManagementApi.csproj b/src/Auth0.ManagementApi/Auth0.ManagementApi.csproj index 3fdaa254e..6ce304b9a 100644 --- a/src/Auth0.ManagementApi/Auth0.ManagementApi.csproj +++ b/src/Auth0.ManagementApi/Auth0.ManagementApi.csproj @@ -5,7 +5,7 @@ enable 12 enable - 7.44.0 + 7.45.1 $(Version) $(Version) README.md diff --git a/src/Auth0.ManagementApi/Clients/ClientsClient.cs b/src/Auth0.ManagementApi/Clients/ClientsClient.cs index 9d4bf84ba..c43784fc6 100644 --- a/src/Auth0.ManagementApi/Clients/ClientsClient.cs +++ b/src/Auth0.ManagementApi/Clients/ClientsClient.cs @@ -267,6 +267,188 @@ private async Task> CreateAsyncCore } } + private async Task< + WithRawResponse + > PreviewCimdMetadataAsyncCore( + PreviewCimdMetadataRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = "clients/cimd/preview", + Body = request, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + private async Task< + WithRawResponse + > RegisterCimdClientAsyncCore( + RegisterCimdClientRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = "clients/cimd/register", + Body = request, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + private async Task> GetAsyncCore( string id, GetClientRequestParameters request, @@ -658,6 +840,48 @@ public WithRawResponseTask CreateAsync( ); } + /// + /// Fetches and validates a Client ID Metadata Document without creating a client. + /// Returns the raw metadata and how it would be mapped to Auth0 client fields. + /// This endpoint is useful for testing metadata URIs before creating CIMD clients. + /// + /// + /// await client.Clients.PreviewCimdMetadataAsync( + /// new PreviewCimdMetadataRequestContent { ExternalClientId = "external_client_id" } + /// ); + /// + public WithRawResponseTask PreviewCimdMetadataAsync( + PreviewCimdMetadataRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + PreviewCimdMetadataAsyncCore(request, options, cancellationToken) + ); + } + + /// + /// Idempotent registration for Client ID Metadata Document (CIMD) clients. + /// Uses external_client_id as the unique identifier for upsert operations. + /// **Create:** Returns 201 when a new client is created (requires \ + /// + /// + /// await client.Clients.RegisterCimdClientAsync( + /// new RegisterCimdClientRequestContent { ExternalClientId = "external_client_id" } + /// ); + /// + public WithRawResponseTask RegisterCimdClientAsync( + RegisterCimdClientRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + RegisterCimdClientAsyncCore(request, options, cancellationToken) + ); + } + /// /// Retrieve client details by ID. Clients are SSO connections or Applications linked with your Auth0 tenant. A list of fields to include or exclude may also be specified. /// For more information, read Applications in Auth0 and Single Sign-On. diff --git a/src/Auth0.ManagementApi/Clients/IClientsClient.cs b/src/Auth0.ManagementApi/Clients/IClientsClient.cs index 084d585a2..fc099e06a 100644 --- a/src/Auth0.ManagementApi/Clients/IClientsClient.cs +++ b/src/Auth0.ManagementApi/Clients/IClientsClient.cs @@ -71,6 +71,28 @@ WithRawResponseTask CreateAsync( CancellationToken cancellationToken = default ); + /// + /// Fetches and validates a Client ID Metadata Document without creating a client. + /// Returns the raw metadata and how it would be mapped to Auth0 client fields. + /// This endpoint is useful for testing metadata URIs before creating CIMD clients. + /// + WithRawResponseTask PreviewCimdMetadataAsync( + PreviewCimdMetadataRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + /// + /// Idempotent registration for Client ID Metadata Document (CIMD) clients. + /// Uses external_client_id as the unique identifier for upsert operations. + /// **Create:** Returns 201 when a new client is created (requires \ + /// + WithRawResponseTask RegisterCimdClientAsync( + RegisterCimdClientRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + /// /// Retrieve client details by ID. Clients are SSO connections or Applications linked with your Auth0 tenant. A list of fields to include or exclude may also be specified. /// For more information, read Applications in Auth0 and Single Sign-On. diff --git a/src/Auth0.ManagementApi/Clients/Requests/PreviewCimdMetadataRequestContent.cs b/src/Auth0.ManagementApi/Clients/Requests/PreviewCimdMetadataRequestContent.cs new file mode 100644 index 000000000..af28ec90b --- /dev/null +++ b/src/Auth0.ManagementApi/Clients/Requests/PreviewCimdMetadataRequestContent.cs @@ -0,0 +1,20 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record PreviewCimdMetadataRequestContent +{ + /// + /// URL to the Client ID Metadata Document + /// + [JsonPropertyName("external_client_id")] + public required string ExternalClientId { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Clients/Requests/RegisterCimdClientRequestContent.cs b/src/Auth0.ManagementApi/Clients/Requests/RegisterCimdClientRequestContent.cs new file mode 100644 index 000000000..c1f5ecad3 --- /dev/null +++ b/src/Auth0.ManagementApi/Clients/Requests/RegisterCimdClientRequestContent.cs @@ -0,0 +1,20 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record RegisterCimdClientRequestContent +{ + /// + /// URL to the Client ID Metadata Document. Acts as the unique identifier for upsert operations. + /// + [JsonPropertyName("external_client_id")] + public required string ExternalClientId { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Core/Public/Version.cs b/src/Auth0.ManagementApi/Core/Public/Version.cs index 750c159dc..bf9617958 100644 --- a/src/Auth0.ManagementApi/Core/Public/Version.cs +++ b/src/Auth0.ManagementApi/Core/Public/Version.cs @@ -3,5 +3,5 @@ namespace Auth0.ManagementApi; [Serializable] internal class Version { - public const string Current = "7.44.0"; + public const string Current = "7.45.1"; } diff --git a/src/Auth0.ManagementApi/CustomDomainHeader.cs b/src/Auth0.ManagementApi/CustomDomainHeader.cs deleted file mode 100644 index 8c26189c2..000000000 --- a/src/Auth0.ManagementApi/CustomDomainHeader.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Auth0.ManagementApi; - -/// -/// Provides constants related to the Auth0 custom domain HTTP header. -/// -/// -/// Use this when constructing a with a custom domain. -/// The header is automatically included on allowed endpoints only. -/// -public static class CustomDomainHeader -{ - /// - /// The HTTP header name used to specify an Auth0 custom domain. - /// - public const string HeaderName = "Auth0-Custom-Domain"; -} diff --git a/src/Auth0.ManagementApi/CustomDomains/CustomDomainsClient.cs b/src/Auth0.ManagementApi/CustomDomains/CustomDomainsClient.cs index 4fd14865a..9ea40b424 100644 --- a/src/Auth0.ManagementApi/CustomDomains/CustomDomainsClient.cs +++ b/src/Auth0.ManagementApi/CustomDomains/CustomDomainsClient.cs @@ -193,6 +193,171 @@ private async Task> CreateAsy } } + private async Task> GetDefaultAsyncCore( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = "custom-domains/default", + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + private async Task> SetDefaultAsyncCore( + SetDefaultCustomDomainRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethodExtensions.Patch, + Path = "custom-domains/default", + Body = request, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + private async Task> GetAsyncCore( string id, RequestOptions? options = null, @@ -615,6 +780,41 @@ public WithRawResponseTask CreateAsync( ); } + /// + /// Retrieve the tenant's default domain. + /// + /// + /// await client.CustomDomains.GetDefaultAsync(); + /// + public WithRawResponseTask GetDefaultAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + GetDefaultAsyncCore(options, cancellationToken) + ); + } + + /// + /// Set the default custom domain for the tenant. + /// + /// + /// await client.CustomDomains.SetDefaultAsync( + /// new SetDefaultCustomDomainRequestContent { Domain = "domain" } + /// ); + /// + public WithRawResponseTask SetDefaultAsync( + SetDefaultCustomDomainRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + SetDefaultAsyncCore(request, options, cancellationToken) + ); + } + /// /// Retrieve a custom domain configuration and status. /// diff --git a/src/Auth0.ManagementApi/CustomDomains/ICustomDomainsClient.cs b/src/Auth0.ManagementApi/CustomDomains/ICustomDomainsClient.cs index 915a38a50..2f9022ddc 100644 --- a/src/Auth0.ManagementApi/CustomDomains/ICustomDomainsClient.cs +++ b/src/Auth0.ManagementApi/CustomDomains/ICustomDomainsClient.cs @@ -33,6 +33,23 @@ WithRawResponseTask CreateAsync( CancellationToken cancellationToken = default ); + /// + /// Retrieve the tenant's default domain. + /// + WithRawResponseTask GetDefaultAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + /// + /// Set the default custom domain for the tenant. + /// + WithRawResponseTask SetDefaultAsync( + SetDefaultCustomDomainRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + /// /// Retrieve a custom domain configuration and status. /// diff --git a/src/Auth0.ManagementApi/CustomDomains/Requests/SetDefaultCustomDomainRequestContent.cs b/src/Auth0.ManagementApi/CustomDomains/Requests/SetDefaultCustomDomainRequestContent.cs new file mode 100644 index 000000000..db09e2e0f --- /dev/null +++ b/src/Auth0.ManagementApi/CustomDomains/Requests/SetDefaultCustomDomainRequestContent.cs @@ -0,0 +1,20 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record SetDefaultCustomDomainRequestContent +{ + /// + /// The domain to set as the default custom domain. Must be a verified custom domain or the canonical domain. + /// + [JsonPropertyName("domain")] + public required string Domain { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Models/Client/AsyncApprovalNotificationChannels.cs b/src/Auth0.ManagementApi/Models/Client/AsyncApprovalNotificationChannels.cs deleted file mode 100644 index 33782e742..000000000 --- a/src/Auth0.ManagementApi/Models/Client/AsyncApprovalNotificationChannels.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Runtime.Serialization; - -namespace Auth0.ManagementApi.Models; - -/// -/// Async approval notification channels for a client -/// -public enum AsyncApprovalNotificationChannels -{ - /// - /// Client uses Guardian Push notification channel with CIBA flow - /// - [EnumMember(Value = "guardian-push")] - GuardianPush, - - /// - /// Client uses email notification channel with CIBA flow - /// - [EnumMember(Value = "email")] - Email -} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Models/Connections/ConnectionAuthenticationPurpose.cs b/src/Auth0.ManagementApi/Models/Connections/ConnectionAuthenticationPurpose.cs deleted file mode 100644 index 0bdf9294f..000000000 --- a/src/Auth0.ManagementApi/Models/Connections/ConnectionAuthenticationPurpose.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Auth0.ManagementApi.Models.Connections; - -/// -/// Configure the purpose of a connection to be used for authentication during login. -/// -public class ConnectionAuthenticationPurpose -{ - [JsonProperty("active")] - public required bool Active { get; set; } -} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Models/Connections/ConnectionConnectedAccountsPurpose.cs b/src/Auth0.ManagementApi/Models/Connections/ConnectionConnectedAccountsPurpose.cs deleted file mode 100644 index aabcd62c9..000000000 --- a/src/Auth0.ManagementApi/Models/Connections/ConnectionConnectedAccountsPurpose.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Newtonsoft.Json; - -namespace Auth0.ManagementApi.Models.Connections; - -/// -/// Configure the purpose of a connection to be used for connected accounts and Token Vault. -/// -public class ConnectionConnectedAccountsPurpose -{ - [JsonProperty("active")] - public required bool Active { get; set; } - - [JsonProperty("cross_app_access")] - public bool? CrossAppAccess { get; set; } -} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Models/Connections/ConnectionOptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Models/Connections/ConnectionOptionsFederatedConnectionsAccessTokens.cs deleted file mode 100644 index 9337fdfef..000000000 --- a/src/Auth0.ManagementApi/Models/Connections/ConnectionOptionsFederatedConnectionsAccessTokens.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Newtonsoft.Json; - -namespace Auth0.ManagementApi.Models.Connections; - -/// -/// Federated Connections Access Tokens -/// -public class ConnectionOptionsFederatedConnectionsAccessTokens -{ - /// - /// Enables refresh tokens and access tokens collection for federated connections - /// - [JsonProperty("active")] - public bool? Active { get; set; } -} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Models/CustomDomain/CustomDomainsGetAllRequest.cs b/src/Auth0.ManagementApi/Models/CustomDomain/CustomDomainsGetAllRequest.cs deleted file mode 100644 index d63d72d5c..000000000 --- a/src/Auth0.ManagementApi/Models/CustomDomain/CustomDomainsGetAllRequest.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Auth0.ManagementApi.Models; - -/// -/// Represents a request to retrieve all custom domains with optional filtering, field selection, and sorting. -/// -public class CustomDomainsGetAllRequest -{ - /// - /// Query in Lucene query string syntax. - /// - public string? Query { get; set; } - - /// - /// Comma-separated list of fields to include or exclude - /// (based on value provided for include_fields) in the result. - /// Leave empty to retrieve all fields. - /// - public string? Fields { get; set; } - - /// - /// Whether specified fields are to be included (true) or excluded (false). - /// - public bool? IncludeFields { get; set; } = null; - - /// - /// Field to sort by. - /// Only domain:1 (ascending order by domain) is supported at this time. - /// - public string? Sort { get; set; } -} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Organizations/Connections/ConnectionsClient.cs b/src/Auth0.ManagementApi/Organizations/Connections/ConnectionsClient.cs new file mode 100644 index 000000000..5dda23cc5 --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Connections/ConnectionsClient.cs @@ -0,0 +1,578 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Core; +using global::System.Text.Json; + +namespace Auth0.ManagementApi.Organizations; + +public partial class ConnectionsClient : IConnectionsClient +{ + private readonly RawClient _client; + + internal ConnectionsClient(RawClient client) + { + _client = client; + } + + private WithRawResponseTask ListInternalAsync( + string id, + ListOrganizationAllConnectionsRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + ListInternalAsyncCore(id, request, options, cancellationToken) + ); + } + + private async Task< + WithRawResponse + > ListInternalAsyncCore( + string id, + ListOrganizationAllConnectionsRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 4) + .Add("page", request.Page.IsDefined ? request.Page.Value : null) + .Add("per_page", request.PerPage.IsDefined ? request.PerPage.Value : null) + .Add( + "include_totals", + request.IncludeTotals.IsDefined ? request.IncludeTotals.Value : null + ) + .Add("is_enabled", request.IsEnabled.IsDefined ? request.IsEnabled.Value : null) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = string.Format( + "organizations/{0}/connections", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = + JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + private async Task< + WithRawResponse + > CreateAsyncCore( + string id, + CreateOrganizationAllConnectionRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = string.Format( + "organizations/{0}/connections", + ValueConvert.ToPathParameterString(id) + ), + Body = request, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = + JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 409: + throw new ConflictError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + private async Task> GetAsyncCore( + string id, + string connectionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = string.Format( + "organizations/{0}/connections/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(connectionId) + ), + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = + JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + private async Task< + WithRawResponse + > UpdateAsyncCore( + string id, + string connectionId, + UpdateOrganizationConnectionRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethodExtensions.Patch, + Path = string.Format( + "organizations/{0}/connections/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(connectionId) + ), + Body = request, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = + JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + /// + /// await client.Organizations.Connections.ListAsync( + /// "id", + /// new ListOrganizationAllConnectionsRequestParameters + /// { + /// Page = 1, + /// PerPage = 1, + /// IncludeTotals = true, + /// IsEnabled = true, + /// } + /// ); + /// + public async Task> ListAsync( + string id, + ListOrganizationAllConnectionsRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + request = request with { }; + var pager = await OffsetPager< + ListOrganizationAllConnectionsRequestParameters, + RequestOptions?, + ListOrganizationAllConnectionsOffsetPaginatedResponseContent, + int?, + int?, + OrganizationAllConnectionPost + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(id, request, options, cancellationToken) + .ConfigureAwait(false), + request => request.Page.GetValueOrDefault(0), + (request, offset) => + { + request.Page = offset; + }, + request => request.PerPage.GetValueOrDefault(0), + response => response.Connections?.ToList(), + null, + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// await client.Organizations.Connections.CreateAsync( + /// "id", + /// new CreateOrganizationAllConnectionRequestParameters { ConnectionId = "connection_id" } + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + CreateOrganizationAllConnectionRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + CreateAsyncCore(id, request, options, cancellationToken) + ); + } + + /// + /// await client.Organizations.Connections.GetAsync("id", "connection_id"); + /// + public WithRawResponseTask GetAsync( + string id, + string connectionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + GetAsyncCore(id, connectionId, options, cancellationToken) + ); + } + + /// + /// await client.Organizations.Connections.DeleteAsync("id", "connection_id"); + /// + public async Task DeleteAsync( + string id, + string connectionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "organizations/{0}/connections/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(connectionId) + ), + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + /// + /// await client.Organizations.Connections.UpdateAsync( + /// "id", + /// "connection_id", + /// new UpdateOrganizationConnectionRequestParameters() + /// ); + /// + public WithRawResponseTask UpdateAsync( + string id, + string connectionId, + UpdateOrganizationConnectionRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + UpdateAsyncCore(id, connectionId, request, options, cancellationToken) + ); + } +} diff --git a/src/Auth0.ManagementApi/Organizations/Connections/IConnectionsClient.cs b/src/Auth0.ManagementApi/Organizations/Connections/IConnectionsClient.cs new file mode 100644 index 000000000..8851587eb --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Connections/IConnectionsClient.cs @@ -0,0 +1,43 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Core; + +namespace Auth0.ManagementApi.Organizations; + +public partial interface IConnectionsClient +{ + Task> ListAsync( + string id, + ListOrganizationAllConnectionsRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + WithRawResponseTask CreateAsync( + string id, + CreateOrganizationAllConnectionRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + WithRawResponseTask GetAsync( + string id, + string connectionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + Task DeleteAsync( + string id, + string connectionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + WithRawResponseTask UpdateAsync( + string id, + string connectionId, + UpdateOrganizationConnectionRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/Auth0.ManagementApi/Organizations/Connections/Requests/CreateOrganizationAllConnectionRequestParameters.cs b/src/Auth0.ManagementApi/Organizations/Connections/Requests/CreateOrganizationAllConnectionRequestParameters.cs new file mode 100644 index 000000000..2d8b09b51 --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Connections/Requests/CreateOrganizationAllConnectionRequestParameters.cs @@ -0,0 +1,60 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi.Organizations; + +[Serializable] +public record CreateOrganizationAllConnectionRequestParameters +{ + /// + /// Name of the connection in the scope of this organization. + /// + [Optional] + [JsonPropertyName("organization_connection_name")] + public string? OrganizationConnectionName { get; set; } + + /// + /// When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection. + /// + [Optional] + [JsonPropertyName("assign_membership_on_login")] + public bool? AssignMembershipOnLogin { get; set; } + + /// + /// Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + /// + /// Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. + /// + [Optional] + [JsonPropertyName("is_signup_enabled")] + public bool? IsSignupEnabled { get; set; } + + [Optional] + [JsonPropertyName("organization_access_level")] + public OrganizationAccessLevelEnum? OrganizationAccessLevel { get; set; } + + /// + /// Whether the connection is enabled for the organization. + /// + [Optional] + [JsonPropertyName("is_enabled")] + public bool? IsEnabled { get; set; } + + /// + /// Connection identifier. + /// + [JsonPropertyName("connection_id")] + public required string ConnectionId { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Organizations/Connections/Requests/ListOrganizationAllConnectionsRequestParameters.cs b/src/Auth0.ManagementApi/Organizations/Connections/Requests/ListOrganizationAllConnectionsRequestParameters.cs new file mode 100644 index 000000000..43cd0edd4 --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Connections/Requests/ListOrganizationAllConnectionsRequestParameters.cs @@ -0,0 +1,38 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi.Organizations; + +[Serializable] +public record ListOrganizationAllConnectionsRequestParameters +{ + /// + /// Page index of the results to return. First page is 0. + /// + [JsonIgnore] + public Optional Page { get; set; } = 0; + + /// + /// Number of results per page. Defaults to 50. + /// + [JsonIgnore] + public Optional PerPage { get; set; } = 50; + + /// + /// Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). + /// + [JsonIgnore] + public Optional IncludeTotals { get; set; } = true; + + /// + /// Filter connections by enabled status. + /// + [JsonIgnore] + public Optional IsEnabled { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Organizations/Connections/Requests/UpdateOrganizationConnectionRequestParameters.cs b/src/Auth0.ManagementApi/Organizations/Connections/Requests/UpdateOrganizationConnectionRequestParameters.cs new file mode 100644 index 000000000..764d30606 --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Connections/Requests/UpdateOrganizationConnectionRequestParameters.cs @@ -0,0 +1,54 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi.Organizations; + +[Serializable] +public record UpdateOrganizationConnectionRequestParameters +{ + /// + /// Name of the connection in the scope of this organization. + /// + [Nullable, Optional] + [JsonPropertyName("organization_connection_name")] + public Optional OrganizationConnectionName { get; set; } + + /// + /// When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection. + /// + [Optional] + [JsonPropertyName("assign_membership_on_login")] + public bool? AssignMembershipOnLogin { get; set; } + + /// + /// Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + /// + /// Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. + /// + [Optional] + [JsonPropertyName("is_signup_enabled")] + public bool? IsSignupEnabled { get; set; } + + [Nullable, Optional] + [JsonPropertyName("organization_access_level")] + public Optional OrganizationAccessLevel { get; set; } + + /// + /// Whether the connection is enabled for the organization. + /// + [Nullable, Optional] + [JsonPropertyName("is_enabled")] + public Optional IsEnabled { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Organizations/IOrganizationsClient.cs b/src/Auth0.ManagementApi/Organizations/IOrganizationsClient.cs index 1d7bfbedc..10c50049a 100644 --- a/src/Auth0.ManagementApi/Organizations/IOrganizationsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/IOrganizationsClient.cs @@ -6,6 +6,7 @@ namespace Auth0.ManagementApi; public partial interface IOrganizationsClient { public Auth0.ManagementApi.Organizations.IClientGrantsClient ClientGrants { get; } + public Auth0.ManagementApi.Organizations.IConnectionsClient Connections { get; } public IDiscoveryDomainsClient DiscoveryDomains { get; } public IEnabledConnectionsClient EnabledConnections { get; } public IInvitationsClient Invitations { get; } diff --git a/src/Auth0.ManagementApi/Organizations/OrganizationsClient.cs b/src/Auth0.ManagementApi/Organizations/OrganizationsClient.cs index 1e36965ff..85dcb86cf 100644 --- a/src/Auth0.ManagementApi/Organizations/OrganizationsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/OrganizationsClient.cs @@ -12,6 +12,7 @@ internal OrganizationsClient(RawClient client) { _client = client; ClientGrants = new Auth0.ManagementApi.Organizations.ClientGrantsClient(_client); + Connections = new Auth0.ManagementApi.Organizations.ConnectionsClient(_client); DiscoveryDomains = new DiscoveryDomainsClient(_client); EnabledConnections = new EnabledConnectionsClient(_client); Invitations = new InvitationsClient(_client); @@ -20,6 +21,8 @@ internal OrganizationsClient(RawClient client) public Auth0.ManagementApi.Organizations.IClientGrantsClient ClientGrants { get; } + public Auth0.ManagementApi.Organizations.IConnectionsClient Connections { get; } + public IDiscoveryDomainsClient DiscoveryDomains { get; } public IEnabledConnectionsClient EnabledConnections { get; } diff --git a/src/Auth0.ManagementApi/RefreshTokens/IRefreshTokensClient.cs b/src/Auth0.ManagementApi/RefreshTokens/IRefreshTokensClient.cs index ad3460d2b..e62c6737f 100644 --- a/src/Auth0.ManagementApi/RefreshTokens/IRefreshTokensClient.cs +++ b/src/Auth0.ManagementApi/RefreshTokens/IRefreshTokensClient.cs @@ -1,7 +1,18 @@ +using Auth0.ManagementApi.Core; + namespace Auth0.ManagementApi; public partial interface IRefreshTokensClient { + /// + /// Retrieve a paginated list of refresh tokens for a specific user, with optional filtering by client ID. Results are sorted by credential_id ascending. + /// + Task> ListAsync( + GetRefreshTokensRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + /// /// Retrieve refresh token information. /// diff --git a/src/Auth0.ManagementApi/RefreshTokens/RefreshTokensClient.cs b/src/Auth0.ManagementApi/RefreshTokens/RefreshTokensClient.cs index 1dca0adcc..997901bc9 100644 --- a/src/Auth0.ManagementApi/RefreshTokens/RefreshTokensClient.cs +++ b/src/Auth0.ManagementApi/RefreshTokens/RefreshTokensClient.cs @@ -12,6 +12,122 @@ internal RefreshTokensClient(RawClient client) _client = client; } + /// + /// Retrieve a paginated list of refresh tokens for a specific user, with optional filtering by client ID. Results are sorted by credential_id ascending. + /// + private WithRawResponseTask ListInternalAsync( + GetRefreshTokensRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + ListInternalAsyncCore(request, options, cancellationToken) + ); + } + + private async Task< + WithRawResponse + > ListInternalAsyncCore( + GetRefreshTokensRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 6) + .Add("user_id", request.UserId) + .Add("client_id", request.ClientId.IsDefined ? request.ClientId.Value : null) + .Add("from", request.From.IsDefined ? request.From.Value : null) + .Add("take", request.Take.IsDefined ? request.Take.Value : null) + .Add("fields", request.Fields.IsDefined ? request.Fields.Value : null) + .Add( + "include_fields", + request.IncludeFields.IsDefined ? request.IncludeFields.Value : null + ) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = "refresh-tokens", + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 429: + throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + private async Task> GetAsyncCore( string id, RequestOptions? options = null, @@ -193,6 +309,56 @@ private async Task> UpdateAsy } } + /// + /// Retrieve a paginated list of refresh tokens for a specific user, with optional filtering by client ID. Results are sorted by credential_id ascending. + /// + /// + /// await client.RefreshTokens.ListAsync( + /// new GetRefreshTokensRequestParameters + /// { + /// UserId = "user_id", + /// ClientId = "client_id", + /// From = "from", + /// Take = 1, + /// Fields = "fields", + /// IncludeFields = true, + /// } + /// ); + /// + public async Task> ListAsync( + GetRefreshTokensRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + if (request is not null) + { + request = request with { }; + } + var pager = await CursorPager< + GetRefreshTokensRequestParameters, + RequestOptions?, + GetRefreshTokensPaginatedResponseContent, + string?, + RefreshTokenResponseContent + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(request, options, cancellationToken), + (request, cursor) => + { + request.From = cursor; + }, + response => response.Next, + response => response.RefreshTokens?.ToList(), + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + /// /// Retrieve refresh token information. /// diff --git a/src/Auth0.ManagementApi/RefreshTokens/Requests/GetRefreshTokensRequestParameters.cs b/src/Auth0.ManagementApi/RefreshTokens/Requests/GetRefreshTokensRequestParameters.cs new file mode 100644 index 000000000..20fdb131c --- /dev/null +++ b/src/Auth0.ManagementApi/RefreshTokens/Requests/GetRefreshTokensRequestParameters.cs @@ -0,0 +1,50 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record GetRefreshTokensRequestParameters +{ + /// + /// ID of the user whose refresh tokens to retrieve. Required. + /// + [JsonIgnore] + public required string UserId { get; set; } + + /// + /// Filter results by client ID. Only valid when user_id is provided. + /// + [JsonIgnore] + public Optional ClientId { get; set; } + + /// + /// An opaque cursor from which to start the selection (exclusive). Expires after 24 hours. Obtained from the next property of a previous response. + /// + [JsonIgnore] + public Optional From { get; set; } + + /// + /// Number of results per page. Defaults to 50. + /// + [JsonIgnore] + public Optional Take { get; set; } = 50; + + /// + /// Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. + /// + [JsonIgnore] + public Optional Fields { get; set; } + + /// + /// Whether specified fields are to be included (true) or excluded (false). + /// + [JsonIgnore] + public Optional IncludeFields { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/CimdMappedClientAuthenticationMethods.cs b/src/Auth0.ManagementApi/Types/CimdMappedClientAuthenticationMethods.cs new file mode 100644 index 000000000..fa8001dca --- /dev/null +++ b/src/Auth0.ManagementApi/Types/CimdMappedClientAuthenticationMethods.cs @@ -0,0 +1,34 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Client authentication methods derived from the JWKS document +/// +[Serializable] +public record CimdMappedClientAuthenticationMethods : IJsonOnDeserialized, IJsonOnSerializing +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("private_key_jwt")] + public CimdMappedClientAuthenticationMethodsPrivateKeyJwt? PrivateKeyJwt { get; set; } + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + void IJsonOnSerializing.OnSerializing() => + AdditionalProperties.CopyToExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/CimdMappedClientAuthenticationMethodsPrivateKeyJwt.cs b/src/Auth0.ManagementApi/Types/CimdMappedClientAuthenticationMethodsPrivateKeyJwt.cs new file mode 100644 index 000000000..1f3c7ba8b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/CimdMappedClientAuthenticationMethodsPrivateKeyJwt.cs @@ -0,0 +1,39 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Private Key JWT authentication configuration +/// +[Serializable] +public record CimdMappedClientAuthenticationMethodsPrivateKeyJwt + : IJsonOnDeserialized, + IJsonOnSerializing +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Credentials derived from the JWKS document + /// + [JsonPropertyName("credentials")] + public IEnumerable Credentials { get; set; } = + new List(); + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + void IJsonOnSerializing.OnSerializing() => + AdditionalProperties.CopyToExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/CimdMappedClientFields.cs b/src/Auth0.ManagementApi/Types/CimdMappedClientFields.cs new file mode 100644 index 000000000..3e8ab5ce3 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/CimdMappedClientFields.cs @@ -0,0 +1,97 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Auth0 client fields mapped from the Client ID Metadata Document +/// +[Serializable] +public record CimdMappedClientFields : IJsonOnDeserialized, IJsonOnSerializing +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The URL of the Client ID Metadata Document + /// + [Optional] + [JsonPropertyName("external_client_id")] + public string? ExternalClientId { get; set; } + + /// + /// Client name + /// + [Optional] + [JsonPropertyName("name")] + public string? Name { get; set; } + + /// + /// Application type (e.g., web, native) + /// + [Optional] + [JsonPropertyName("app_type")] + public string? AppType { get; set; } + + /// + /// Callback URLs + /// + [Optional] + [JsonPropertyName("callbacks")] + public IEnumerable? Callbacks { get; set; } + + /// + /// Logo URI + /// + [Optional] + [JsonPropertyName("logo_uri")] + public string? LogoUri { get; set; } + + /// + /// Human-readable brief description of this client presentable to the end-user + /// + [Optional] + [JsonPropertyName("description")] + public string? Description { get; set; } + + /// + /// List of grant types + /// + [Optional] + [JsonPropertyName("grant_types")] + public IEnumerable? GrantTypes { get; set; } + + /// + /// Token endpoint authentication method + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_method")] + public string? TokenEndpointAuthMethod { get; set; } + + /// + /// URL for the JSON Web Key Set containing the public keys for private_key_jwt authentication + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + + [Optional] + [JsonPropertyName("client_authentication_methods")] + public CimdMappedClientAuthenticationMethods? ClientAuthenticationMethods { get; set; } + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + void IJsonOnSerializing.OnSerializing() => + AdditionalProperties.CopyToExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/CimdMappedPrivateKeyJwtCredential.cs b/src/Auth0.ManagementApi/Types/CimdMappedPrivateKeyJwtCredential.cs new file mode 100644 index 000000000..3089e859f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/CimdMappedPrivateKeyJwtCredential.cs @@ -0,0 +1,45 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record CimdMappedPrivateKeyJwtCredential : IJsonOnDeserialized, IJsonOnSerializing +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Type of credential (e.g., public_key) + /// + [JsonPropertyName("credential_type")] + public required string CredentialType { get; set; } + + /// + /// Key identifier from JWKS or calculated thumbprint + /// + [JsonPropertyName("kid")] + public required string Kid { get; set; } + + /// + /// Algorithm (e.g., RS256, RS384, PS256) + /// + [JsonPropertyName("alg")] + public required string Alg { get; set; } + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + void IJsonOnSerializing.OnSerializing() => + AdditionalProperties.CopyToExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/CimdValidationResult.cs b/src/Auth0.ManagementApi/Types/CimdValidationResult.cs new file mode 100644 index 000000000..a89b866ca --- /dev/null +++ b/src/Auth0.ManagementApi/Types/CimdValidationResult.cs @@ -0,0 +1,48 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Validation result for the Client ID Metadata Document +/// +[Serializable] +public record CimdValidationResult : IJsonOnDeserialized, IJsonOnSerializing +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Whether the metadata document passed validation + /// + [JsonPropertyName("valid")] + public required bool Valid { get; set; } + + /// + /// Array of validation violation messages (if any) + /// + [JsonPropertyName("violations")] + public IEnumerable Violations { get; set; } = new List(); + + /// + /// Array of warning messages (if any) + /// + [JsonPropertyName("warnings")] + public IEnumerable Warnings { get; set; } = new List(); + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + void IJsonOnSerializing.OnSerializing() => + AdditionalProperties.CopyToExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/Client.cs b/src/Auth0.ManagementApi/Types/Client.cs index 0d1d286c7..6be1d6574 100644 --- a/src/Auth0.ManagementApi/Types/Client.cs +++ b/src/Auth0.ManagementApi/Types/Client.cs @@ -320,6 +320,28 @@ public record Client : IJsonOnDeserialized, IJsonOnSerializing [JsonPropertyName("async_approval_notification_channels")] public IEnumerable? AsyncApprovalNotificationChannels { get; set; } + [Optional] + [JsonPropertyName("external_metadata_type")] + public ClientExternalMetadataTypeEnum? ExternalMetadataType { get; set; } + + [Optional] + [JsonPropertyName("external_metadata_created_by")] + public ClientExternalMetadataCreatedByEnum? ExternalMetadataCreatedBy { get; set; } + + /// + /// An alternate client identifier to be used during authorization flows. Only supports CIMD-based client identifiers. + /// + [Optional] + [JsonPropertyName("external_client_id")] + public string? ExternalClientId { get; set; } + + /// + /// URL for the JSON Web Key Set (JWKS) containing the public keys used for private_key_jwt authentication. Only present for CIMD clients using private_key_jwt authentication. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/ConnectionResponseContentFlickrStrategy.cs b/src/Auth0.ManagementApi/Types/ClientExternalMetadataCreatedByEnum.cs similarity index 56% rename from src/Auth0.ManagementApi/Types/ConnectionResponseContentFlickrStrategy.cs rename to src/Auth0.ManagementApi/Types/ClientExternalMetadataCreatedByEnum.cs index a3862a068..814489b20 100644 --- a/src/Auth0.ManagementApi/Types/ConnectionResponseContentFlickrStrategy.cs +++ b/src/Auth0.ManagementApi/Types/ClientExternalMetadataCreatedByEnum.cs @@ -5,14 +5,16 @@ namespace Auth0.ManagementApi; [JsonConverter( - typeof(ConnectionResponseContentFlickrStrategy.ConnectionResponseContentFlickrStrategySerializer) + typeof(ClientExternalMetadataCreatedByEnum.ClientExternalMetadataCreatedByEnumSerializer) )] [Serializable] -public readonly record struct ConnectionResponseContentFlickrStrategy : IStringEnum +public readonly record struct ClientExternalMetadataCreatedByEnum : IStringEnum { - public static readonly ConnectionResponseContentFlickrStrategy Flickr = new(Values.Flickr); + public static readonly ClientExternalMetadataCreatedByEnum Admin = new(Values.Admin); - public ConnectionResponseContentFlickrStrategy(string value) + public static readonly ClientExternalMetadataCreatedByEnum Client = new(Values.Client); + + public ClientExternalMetadataCreatedByEnum(string value) { Value = value; } @@ -25,9 +27,9 @@ public ConnectionResponseContentFlickrStrategy(string value) /// /// Create a string enum with the given value. /// - public static ConnectionResponseContentFlickrStrategy FromCustom(string value) + public static ClientExternalMetadataCreatedByEnum FromCustom(string value) { - return new ConnectionResponseContentFlickrStrategy(value); + return new ClientExternalMetadataCreatedByEnum(value); } public bool Equals(string? other) @@ -43,22 +45,21 @@ public override string ToString() return Value; } - public static bool operator ==(ConnectionResponseContentFlickrStrategy value1, string value2) => + public static bool operator ==(ClientExternalMetadataCreatedByEnum value1, string value2) => value1.Value.Equals(value2); - public static bool operator !=(ConnectionResponseContentFlickrStrategy value1, string value2) => + public static bool operator !=(ClientExternalMetadataCreatedByEnum value1, string value2) => !value1.Value.Equals(value2); - public static explicit operator string(ConnectionResponseContentFlickrStrategy value) => + public static explicit operator string(ClientExternalMetadataCreatedByEnum value) => value.Value; - public static explicit operator ConnectionResponseContentFlickrStrategy(string value) => - new(value); + public static explicit operator ClientExternalMetadataCreatedByEnum(string value) => new(value); - internal class ConnectionResponseContentFlickrStrategySerializer - : JsonConverter + internal class ClientExternalMetadataCreatedByEnumSerializer + : JsonConverter { - public override ConnectionResponseContentFlickrStrategy Read( + public override ClientExternalMetadataCreatedByEnum Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -69,19 +70,19 @@ JsonSerializerOptions options ?? throw new global::System.Exception( "The JSON value could not be read as a string." ); - return new ConnectionResponseContentFlickrStrategy(stringValue); + return new ClientExternalMetadataCreatedByEnum(stringValue); } public override void Write( Utf8JsonWriter writer, - ConnectionResponseContentFlickrStrategy value, + ClientExternalMetadataCreatedByEnum value, JsonSerializerOptions options ) { writer.WriteStringValue(value.Value); } - public override ConnectionResponseContentFlickrStrategy ReadAsPropertyName( + public override ClientExternalMetadataCreatedByEnum ReadAsPropertyName( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -92,12 +93,12 @@ JsonSerializerOptions options ?? throw new global::System.Exception( "The JSON property name could not be read as a string." ); - return new ConnectionResponseContentFlickrStrategy(stringValue); + return new ClientExternalMetadataCreatedByEnum(stringValue); } public override void WriteAsPropertyName( Utf8JsonWriter writer, - ConnectionResponseContentFlickrStrategy value, + ClientExternalMetadataCreatedByEnum value, JsonSerializerOptions options ) { @@ -111,6 +112,8 @@ JsonSerializerOptions options [Serializable] public static class Values { - public const string Flickr = "flickr"; + public const string Admin = "admin"; + + public const string Client = "client"; } } diff --git a/src/Auth0.ManagementApi/Types/ConnectionResponseContentAolStrategy.cs b/src/Auth0.ManagementApi/Types/ClientExternalMetadataTypeEnum.cs similarity index 57% rename from src/Auth0.ManagementApi/Types/ConnectionResponseContentAolStrategy.cs rename to src/Auth0.ManagementApi/Types/ClientExternalMetadataTypeEnum.cs index a9d5f0341..eafc6dbcc 100644 --- a/src/Auth0.ManagementApi/Types/ConnectionResponseContentAolStrategy.cs +++ b/src/Auth0.ManagementApi/Types/ClientExternalMetadataTypeEnum.cs @@ -4,15 +4,13 @@ namespace Auth0.ManagementApi; -[JsonConverter( - typeof(ConnectionResponseContentAolStrategy.ConnectionResponseContentAolStrategySerializer) -)] +[JsonConverter(typeof(ClientExternalMetadataTypeEnum.ClientExternalMetadataTypeEnumSerializer))] [Serializable] -public readonly record struct ConnectionResponseContentAolStrategy : IStringEnum +public readonly record struct ClientExternalMetadataTypeEnum : IStringEnum { - public static readonly ConnectionResponseContentAolStrategy Aol = new(Values.Aol); + public static readonly ClientExternalMetadataTypeEnum Cimd = new(Values.Cimd); - public ConnectionResponseContentAolStrategy(string value) + public ClientExternalMetadataTypeEnum(string value) { Value = value; } @@ -25,9 +23,9 @@ public ConnectionResponseContentAolStrategy(string value) /// /// Create a string enum with the given value. /// - public static ConnectionResponseContentAolStrategy FromCustom(string value) + public static ClientExternalMetadataTypeEnum FromCustom(string value) { - return new ConnectionResponseContentAolStrategy(value); + return new ClientExternalMetadataTypeEnum(value); } public bool Equals(string? other) @@ -43,22 +41,20 @@ public override string ToString() return Value; } - public static bool operator ==(ConnectionResponseContentAolStrategy value1, string value2) => + public static bool operator ==(ClientExternalMetadataTypeEnum value1, string value2) => value1.Value.Equals(value2); - public static bool operator !=(ConnectionResponseContentAolStrategy value1, string value2) => + public static bool operator !=(ClientExternalMetadataTypeEnum value1, string value2) => !value1.Value.Equals(value2); - public static explicit operator string(ConnectionResponseContentAolStrategy value) => - value.Value; + public static explicit operator string(ClientExternalMetadataTypeEnum value) => value.Value; - public static explicit operator ConnectionResponseContentAolStrategy(string value) => - new(value); + public static explicit operator ClientExternalMetadataTypeEnum(string value) => new(value); - internal class ConnectionResponseContentAolStrategySerializer - : JsonConverter + internal class ClientExternalMetadataTypeEnumSerializer + : JsonConverter { - public override ConnectionResponseContentAolStrategy Read( + public override ClientExternalMetadataTypeEnum Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -69,19 +65,19 @@ JsonSerializerOptions options ?? throw new global::System.Exception( "The JSON value could not be read as a string." ); - return new ConnectionResponseContentAolStrategy(stringValue); + return new ClientExternalMetadataTypeEnum(stringValue); } public override void Write( Utf8JsonWriter writer, - ConnectionResponseContentAolStrategy value, + ClientExternalMetadataTypeEnum value, JsonSerializerOptions options ) { writer.WriteStringValue(value.Value); } - public override ConnectionResponseContentAolStrategy ReadAsPropertyName( + public override ClientExternalMetadataTypeEnum ReadAsPropertyName( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -92,12 +88,12 @@ JsonSerializerOptions options ?? throw new global::System.Exception( "The JSON property name could not be read as a string." ); - return new ConnectionResponseContentAolStrategy(stringValue); + return new ClientExternalMetadataTypeEnum(stringValue); } public override void WriteAsPropertyName( Utf8JsonWriter writer, - ConnectionResponseContentAolStrategy value, + ClientExternalMetadataTypeEnum value, JsonSerializerOptions options ) { @@ -111,6 +107,6 @@ JsonSerializerOptions options [Serializable] public static class Values { - public const string Aol = "aol"; + public const string Cimd = "cimd"; } } diff --git a/src/Auth0.ManagementApi/Types/ConnectionIdentityProviderEnum.cs b/src/Auth0.ManagementApi/Types/ConnectionIdentityProviderEnum.cs index 8801065b2..98b612fdd 100644 --- a/src/Auth0.ManagementApi/Types/ConnectionIdentityProviderEnum.cs +++ b/src/Auth0.ManagementApi/Types/ConnectionIdentityProviderEnum.cs @@ -20,8 +20,6 @@ namespace Auth0.ManagementApi; public static readonly ConnectionIdentityProviderEnum Bitbucket = new(Values.Bitbucket); - public static readonly ConnectionIdentityProviderEnum Aol = new(Values.Aol); - public static readonly ConnectionIdentityProviderEnum Auth0Oidc = new(Values.Auth0Oidc); public static readonly ConnectionIdentityProviderEnum Auth0 = new(Values.Auth0); @@ -52,8 +50,6 @@ namespace Auth0.ManagementApi; public static readonly ConnectionIdentityProviderEnum Fitbit = new(Values.Fitbit); - public static readonly ConnectionIdentityProviderEnum Flickr = new(Values.Flickr); - public static readonly ConnectionIdentityProviderEnum Github = new(Values.Github); public static readonly ConnectionIdentityProviderEnum GoogleApps = new(Values.GoogleApps); @@ -241,8 +237,6 @@ public static class Values public const string Bitbucket = "bitbucket"; - public const string Aol = "aol"; - public const string Auth0Oidc = "auth0-oidc"; public const string Auth0 = "auth0"; @@ -271,8 +265,6 @@ public static class Values public const string Fitbit = "fitbit"; - public const string Flickr = "flickr"; - public const string Github = "github"; public const string GoogleApps = "google-apps"; diff --git a/src/Auth0.ManagementApi/Types/ConnectionOptionsFlickr.cs b/src/Auth0.ManagementApi/Types/ConnectionOptionsFlickr.cs deleted file mode 100644 index 67a015afe..000000000 --- a/src/Auth0.ManagementApi/Types/ConnectionOptionsFlickr.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Auth0.ManagementApi.Core; -using global::System.Text.Json.Serialization; - -namespace Auth0.ManagementApi; - -/// -/// Options for the 'flickr' connection -/// -[Serializable] -public record ConnectionOptionsFlickr : IJsonOnDeserialized, IJsonOnSerializing -{ - [JsonExtensionData] - private readonly IDictionary _extensionData = - new Dictionary(); - - /// - /// OAuth 1.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. - /// - [Optional] - [JsonPropertyName("client_id")] - public string? ClientId { get; set; } - - /// - /// OAuth 1.0 client secret issued by the identity provider during application registration. Used to authenticate your Auth0 connection when signing requests and exchanging request tokens and verifiers for access tokens. May be null for public clients. - /// - [Optional] - [JsonPropertyName("client_secret")] - public string? ClientSecret { get; set; } - - [Optional] - [JsonPropertyName("set_user_root_attributes")] - public ConnectionSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } - - [Nullable, Optional] - [JsonPropertyName("upstream_params")] - public Optional?> UpstreamParams { get; set; } - - [Optional] - [JsonPropertyName("non_persistent_attrs")] - public IEnumerable? NonPersistentAttrs { get; set; } - - [JsonIgnore] - public AdditionalProperties AdditionalProperties { get; set; } = new(); - - void IJsonOnDeserialized.OnDeserialized() => - AdditionalProperties.CopyFromExtensionData(_extensionData); - - void IJsonOnSerializing.OnSerializing() => - AdditionalProperties.CopyToExtensionData(_extensionData); - - /// - public override string ToString() - { - return JsonUtils.Serialize(this); - } -} diff --git a/src/Auth0.ManagementApi/Types/ConnectionResponseContentAol.cs b/src/Auth0.ManagementApi/Types/ConnectionResponseContentAol.cs deleted file mode 100644 index 4f33056e1..000000000 --- a/src/Auth0.ManagementApi/Types/ConnectionResponseContentAol.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Auth0.ManagementApi.Core; -using global::System.Text.Json; -using global::System.Text.Json.Serialization; - -namespace Auth0.ManagementApi; - -/// -/// Response for connections with strategy=aol -/// -[Serializable] -public record ConnectionResponseContentAol : IJsonOnDeserialized -{ - [JsonExtensionData] - private readonly IDictionary _extensionData = - new Dictionary(); - - [JsonPropertyName("strategy")] - public required ConnectionResponseContentAolStrategy Strategy { get; set; } - - [Optional] - [JsonPropertyName("options")] - public ConnectionOptionsAol? Options { get; set; } - - [Optional] - [JsonPropertyName("authentication")] - public ConnectionAuthenticationPurpose? Authentication { get; set; } - - [Optional] - [JsonPropertyName("connected_accounts")] - public ConnectionConnectedAccountsPurpose? ConnectedAccounts { get; set; } - - [JsonPropertyName("id")] - public required string Id { get; set; } - - [Optional] - [JsonPropertyName("realms")] - public IEnumerable? Realms { get; set; } - - [JsonPropertyName("name")] - public required string Name { get; set; } - - /// - /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. - /// - [Optional] - [JsonPropertyName("enabled_clients")] - public IEnumerable? EnabledClients { get; set; } - - [Optional] - [JsonPropertyName("display_name")] - public string? DisplayName { get; set; } - - [Optional] - [JsonPropertyName("is_domain_connection")] - public bool? IsDomainConnection { get; set; } - - [Optional] - [JsonPropertyName("metadata")] - public Dictionary? Metadata { get; set; } - - [JsonIgnore] - public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); - - void IJsonOnDeserialized.OnDeserialized() => - AdditionalProperties.CopyFromExtensionData(_extensionData); - - /// - public override string ToString() - { - return JsonUtils.Serialize(this); - } -} diff --git a/src/Auth0.ManagementApi/Types/ConnectionResponseContentFlickr.cs b/src/Auth0.ManagementApi/Types/ConnectionResponseContentFlickr.cs deleted file mode 100644 index bee01eff2..000000000 --- a/src/Auth0.ManagementApi/Types/ConnectionResponseContentFlickr.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Auth0.ManagementApi.Core; -using global::System.Text.Json; -using global::System.Text.Json.Serialization; - -namespace Auth0.ManagementApi; - -/// -/// Response for connections with strategy=flickr -/// -[Serializable] -public record ConnectionResponseContentFlickr : IJsonOnDeserialized -{ - [JsonExtensionData] - private readonly IDictionary _extensionData = - new Dictionary(); - - [JsonPropertyName("strategy")] - public required ConnectionResponseContentFlickrStrategy Strategy { get; set; } - - [Optional] - [JsonPropertyName("options")] - public ConnectionOptionsFlickr? Options { get; set; } - - [Optional] - [JsonPropertyName("authentication")] - public ConnectionAuthenticationPurpose? Authentication { get; set; } - - [Optional] - [JsonPropertyName("connected_accounts")] - public ConnectionConnectedAccountsPurpose? ConnectedAccounts { get; set; } - - [JsonPropertyName("id")] - public required string Id { get; set; } - - [Optional] - [JsonPropertyName("realms")] - public IEnumerable? Realms { get; set; } - - [JsonPropertyName("name")] - public required string Name { get; set; } - - /// - /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. - /// - [Optional] - [JsonPropertyName("enabled_clients")] - public IEnumerable? EnabledClients { get; set; } - - [Optional] - [JsonPropertyName("display_name")] - public string? DisplayName { get; set; } - - [Optional] - [JsonPropertyName("is_domain_connection")] - public bool? IsDomainConnection { get; set; } - - [Optional] - [JsonPropertyName("metadata")] - public Dictionary? Metadata { get; set; } - - [JsonIgnore] - public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); - - void IJsonOnDeserialized.OnDeserialized() => - AdditionalProperties.CopyFromExtensionData(_extensionData); - - /// - public override string ToString() - { - return JsonUtils.Serialize(this); - } -} diff --git a/src/Auth0.ManagementApi/Types/ConnectionStrategyEnum.cs b/src/Auth0.ManagementApi/Types/ConnectionStrategyEnum.cs index 56c035323..7a9da5d6c 100644 --- a/src/Auth0.ManagementApi/Types/ConnectionStrategyEnum.cs +++ b/src/Auth0.ManagementApi/Types/ConnectionStrategyEnum.cs @@ -20,8 +20,6 @@ namespace Auth0.ManagementApi; public static readonly ConnectionStrategyEnum Bitbucket = new(Values.Bitbucket); - public static readonly ConnectionStrategyEnum Aol = new(Values.Aol); - public static readonly ConnectionStrategyEnum Auth0Oidc = new(Values.Auth0Oidc); public static readonly ConnectionStrategyEnum Auth0 = new(Values.Auth0); @@ -50,8 +48,6 @@ namespace Auth0.ManagementApi; public static readonly ConnectionStrategyEnum Fitbit = new(Values.Fitbit); - public static readonly ConnectionStrategyEnum Flickr = new(Values.Flickr); - public static readonly ConnectionStrategyEnum Github = new(Values.Github); public static readonly ConnectionStrategyEnum GoogleApps = new(Values.GoogleApps); @@ -236,8 +232,6 @@ public static class Values public const string Bitbucket = "bitbucket"; - public const string Aol = "aol"; - public const string Auth0Oidc = "auth0-oidc"; public const string Auth0 = "auth0"; @@ -266,8 +260,6 @@ public static class Values public const string Fitbit = "fitbit"; - public const string Flickr = "flickr"; - public const string Github = "github"; public const string GoogleApps = "google-apps"; diff --git a/src/Auth0.ManagementApi/Types/CreateClientResponseContent.cs b/src/Auth0.ManagementApi/Types/CreateClientResponseContent.cs index 33c359bc5..1e146f2b6 100644 --- a/src/Auth0.ManagementApi/Types/CreateClientResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/CreateClientResponseContent.cs @@ -320,6 +320,28 @@ public record CreateClientResponseContent : IJsonOnDeserialized, IJsonOnSerializ [JsonPropertyName("async_approval_notification_channels")] public IEnumerable? AsyncApprovalNotificationChannels { get; set; } + [Optional] + [JsonPropertyName("external_metadata_type")] + public ClientExternalMetadataTypeEnum? ExternalMetadataType { get; set; } + + [Optional] + [JsonPropertyName("external_metadata_created_by")] + public ClientExternalMetadataCreatedByEnum? ExternalMetadataCreatedBy { get; set; } + + /// + /// An alternate client identifier to be used during authorization flows. Only supports CIMD-based client identifiers. + /// + [Optional] + [JsonPropertyName("external_client_id")] + public string? ExternalClientId { get; set; } + + /// + /// URL for the JSON Web Key Set (JWKS) containing the public keys used for private_key_jwt authentication. Only present for CIMD clients using private_key_jwt authentication. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentAol.cs b/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentAol.cs deleted file mode 100644 index e64b285e5..000000000 --- a/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentAol.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Auth0.ManagementApi.Core; -using global::System.Text.Json; -using global::System.Text.Json.Serialization; - -namespace Auth0.ManagementApi; - -/// -/// Create a connection with strategy=aol -/// -[Serializable] -public record CreateConnectionRequestContentAol : IJsonOnDeserialized -{ - [JsonExtensionData] - private readonly IDictionary _extensionData = - new Dictionary(); - - [JsonPropertyName("strategy")] - public required CreateConnectionRequestContentAolStrategy Strategy { get; set; } - - [Optional] - [JsonPropertyName("options")] - public ConnectionOptionsAol? Options { get; set; } - - [JsonPropertyName("name")] - public required string Name { get; set; } - - /// - /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. - /// - [Optional] - [JsonPropertyName("enabled_clients")] - public IEnumerable? EnabledClients { get; set; } - - [Optional] - [JsonPropertyName("display_name")] - public string? DisplayName { get; set; } - - [Optional] - [JsonPropertyName("is_domain_connection")] - public bool? IsDomainConnection { get; set; } - - [Optional] - [JsonPropertyName("metadata")] - public Dictionary? Metadata { get; set; } - - [JsonIgnore] - public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); - - void IJsonOnDeserialized.OnDeserialized() => - AdditionalProperties.CopyFromExtensionData(_extensionData); - - /// - public override string ToString() - { - return JsonUtils.Serialize(this); - } -} diff --git a/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentFlickr.cs b/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentFlickr.cs deleted file mode 100644 index dd459ffe2..000000000 --- a/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentFlickr.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Auth0.ManagementApi.Core; -using global::System.Text.Json; -using global::System.Text.Json.Serialization; - -namespace Auth0.ManagementApi; - -/// -/// Create a connection with strategy=flickr -/// -[Serializable] -public record CreateConnectionRequestContentFlickr : IJsonOnDeserialized -{ - [JsonExtensionData] - private readonly IDictionary _extensionData = - new Dictionary(); - - [JsonPropertyName("strategy")] - public required CreateConnectionRequestContentFlickrStrategy Strategy { get; set; } - - [Optional] - [JsonPropertyName("options")] - public ConnectionOptionsFlickr? Options { get; set; } - - [JsonPropertyName("name")] - public required string Name { get; set; } - - /// - /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. - /// - [Optional] - [JsonPropertyName("enabled_clients")] - public IEnumerable? EnabledClients { get; set; } - - [Optional] - [JsonPropertyName("display_name")] - public string? DisplayName { get; set; } - - [Optional] - [JsonPropertyName("is_domain_connection")] - public bool? IsDomainConnection { get; set; } - - [Optional] - [JsonPropertyName("metadata")] - public Dictionary? Metadata { get; set; } - - [JsonIgnore] - public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); - - void IJsonOnDeserialized.OnDeserialized() => - AdditionalProperties.CopyFromExtensionData(_extensionData); - - /// - public override string ToString() - { - return JsonUtils.Serialize(this); - } -} diff --git a/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentFlickrStrategy.cs b/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentFlickrStrategy.cs deleted file mode 100644 index 2c5e916c1..000000000 --- a/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentFlickrStrategy.cs +++ /dev/null @@ -1,120 +0,0 @@ -using Auth0.ManagementApi.Core; -using global::System.Text.Json; -using global::System.Text.Json.Serialization; - -namespace Auth0.ManagementApi; - -[JsonConverter( - typeof(CreateConnectionRequestContentFlickrStrategy.CreateConnectionRequestContentFlickrStrategySerializer) -)] -[Serializable] -public readonly record struct CreateConnectionRequestContentFlickrStrategy : IStringEnum -{ - public static readonly CreateConnectionRequestContentFlickrStrategy Flickr = new(Values.Flickr); - - public CreateConnectionRequestContentFlickrStrategy(string value) - { - Value = value; - } - - /// - /// The string value of the enum. - /// - public string Value { get; } - - /// - /// Create a string enum with the given value. - /// - public static CreateConnectionRequestContentFlickrStrategy FromCustom(string value) - { - return new CreateConnectionRequestContentFlickrStrategy(value); - } - - public bool Equals(string? other) - { - return Value.Equals(other); - } - - /// - /// Returns the string value of the enum. - /// - public override string ToString() - { - return Value; - } - - public static bool operator ==( - CreateConnectionRequestContentFlickrStrategy value1, - string value2 - ) => value1.Value.Equals(value2); - - public static bool operator !=( - CreateConnectionRequestContentFlickrStrategy value1, - string value2 - ) => !value1.Value.Equals(value2); - - public static explicit operator string(CreateConnectionRequestContentFlickrStrategy value) => - value.Value; - - public static explicit operator CreateConnectionRequestContentFlickrStrategy(string value) => - new(value); - - internal class CreateConnectionRequestContentFlickrStrategySerializer - : JsonConverter - { - public override CreateConnectionRequestContentFlickrStrategy Read( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var stringValue = - reader.GetString() - ?? throw new global::System.Exception( - "The JSON value could not be read as a string." - ); - return new CreateConnectionRequestContentFlickrStrategy(stringValue); - } - - public override void Write( - Utf8JsonWriter writer, - CreateConnectionRequestContentFlickrStrategy value, - JsonSerializerOptions options - ) - { - writer.WriteStringValue(value.Value); - } - - public override CreateConnectionRequestContentFlickrStrategy ReadAsPropertyName( - ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options - ) - { - var stringValue = - reader.GetString() - ?? throw new global::System.Exception( - "The JSON property name could not be read as a string." - ); - return new CreateConnectionRequestContentFlickrStrategy(stringValue); - } - - public override void WriteAsPropertyName( - Utf8JsonWriter writer, - CreateConnectionRequestContentFlickrStrategy value, - JsonSerializerOptions options - ) - { - writer.WritePropertyName(value.Value); - } - } - - /// - /// Constant strings for enum values - /// - [Serializable] - public static class Values - { - public const string Flickr = "flickr"; - } -} diff --git a/src/Auth0.ManagementApi/Types/CreateDirectoryProvisioningRequestContent.cs b/src/Auth0.ManagementApi/Types/CreateDirectoryProvisioningRequestContent.cs index 8a219f877..b39afe9d5 100644 --- a/src/Auth0.ManagementApi/Types/CreateDirectoryProvisioningRequestContent.cs +++ b/src/Auth0.ManagementApi/Types/CreateDirectoryProvisioningRequestContent.cs @@ -27,7 +27,7 @@ public record CreateDirectoryProvisioningRequestContent : IJsonOnDeserialized [Optional] [JsonPropertyName("synchronize_groups")] - public string? SynchronizeGroups { get; set; } + public SynchronizeGroupsEnum? SynchronizeGroups { get; set; } [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/CreateDirectoryProvisioningResponseContent.cs b/src/Auth0.ManagementApi/Types/CreateDirectoryProvisioningResponseContent.cs index 378923a11..1a801c8c8 100644 --- a/src/Auth0.ManagementApi/Types/CreateDirectoryProvisioningResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/CreateDirectoryProvisioningResponseContent.cs @@ -44,7 +44,7 @@ public record CreateDirectoryProvisioningResponseContent : IJsonOnDeserialized [Optional] [JsonPropertyName("synchronize_groups")] - public string? SynchronizeGroups { get; set; } + public SynchronizeGroupsEnum? SynchronizeGroups { get; set; } /// /// The timestamp at which the directory provisioning configuration was created diff --git a/src/Auth0.ManagementApi/Types/CreateOrganizationAllConnectionResponseContent.cs b/src/Auth0.ManagementApi/Types/CreateOrganizationAllConnectionResponseContent.cs new file mode 100644 index 000000000..b18a1046c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/CreateOrganizationAllConnectionResponseContent.cs @@ -0,0 +1,74 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record CreateOrganizationAllConnectionResponseContent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Name of the connection in the scope of this organization. + /// + [Optional] + [JsonPropertyName("organization_connection_name")] + public string? OrganizationConnectionName { get; set; } + + /// + /// When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection. + /// + [Optional] + [JsonPropertyName("assign_membership_on_login")] + public bool? AssignMembershipOnLogin { get; set; } + + /// + /// Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + /// + /// Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. + /// + [Optional] + [JsonPropertyName("is_signup_enabled")] + public bool? IsSignupEnabled { get; set; } + + [Optional] + [JsonPropertyName("organization_access_level")] + public OrganizationAccessLevelEnum? OrganizationAccessLevel { get; set; } + + /// + /// Whether the connection is enabled for the organization. + /// + [Optional] + [JsonPropertyName("is_enabled")] + public bool? IsEnabled { get; set; } + + /// + /// Connection identifier. + /// + [JsonPropertyName("connection_id")] + public required string ConnectionId { get; set; } + + [Optional] + [JsonPropertyName("connection")] + public OrganizationConnectionInformation? Connection { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/DirectoryProvisioning.cs b/src/Auth0.ManagementApi/Types/DirectoryProvisioning.cs index e973e0df5..7e5e51901 100644 --- a/src/Auth0.ManagementApi/Types/DirectoryProvisioning.cs +++ b/src/Auth0.ManagementApi/Types/DirectoryProvisioning.cs @@ -44,7 +44,7 @@ public record DirectoryProvisioning : IJsonOnDeserialized [Optional] [JsonPropertyName("synchronize_groups")] - public string? SynchronizeGroups { get; set; } + public SynchronizeGroupsEnum? SynchronizeGroups { get; set; } /// /// The timestamp at which the directory provisioning configuration was created diff --git a/src/Auth0.ManagementApi/Types/GetClientResponseContent.cs b/src/Auth0.ManagementApi/Types/GetClientResponseContent.cs index 1ccd7dc39..0e0bee97f 100644 --- a/src/Auth0.ManagementApi/Types/GetClientResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/GetClientResponseContent.cs @@ -320,6 +320,28 @@ public record GetClientResponseContent : IJsonOnDeserialized, IJsonOnSerializing [JsonPropertyName("async_approval_notification_channels")] public IEnumerable? AsyncApprovalNotificationChannels { get; set; } + [Optional] + [JsonPropertyName("external_metadata_type")] + public ClientExternalMetadataTypeEnum? ExternalMetadataType { get; set; } + + [Optional] + [JsonPropertyName("external_metadata_created_by")] + public ClientExternalMetadataCreatedByEnum? ExternalMetadataCreatedBy { get; set; } + + /// + /// An alternate client identifier to be used during authorization flows. Only supports CIMD-based client identifiers. + /// + [Optional] + [JsonPropertyName("external_client_id")] + public string? ExternalClientId { get; set; } + + /// + /// URL for the JSON Web Key Set (JWKS) containing the public keys used for private_key_jwt authentication. Only present for CIMD clients using private_key_jwt authentication. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/GetDefaultCanonicalDomainResponseContent.cs b/src/Auth0.ManagementApi/Types/GetDefaultCanonicalDomainResponseContent.cs new file mode 100644 index 000000000..e00e76cdf --- /dev/null +++ b/src/Auth0.ManagementApi/Types/GetDefaultCanonicalDomainResponseContent.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record GetDefaultCanonicalDomainResponseContent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Domain name. + /// + [JsonPropertyName("domain")] + public required string Domain { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/GetDefaultCustomDomainResponseContent.cs b/src/Auth0.ManagementApi/Types/GetDefaultCustomDomainResponseContent.cs new file mode 100644 index 000000000..b0c339b7a --- /dev/null +++ b/src/Auth0.ManagementApi/Types/GetDefaultCustomDomainResponseContent.cs @@ -0,0 +1,96 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record GetDefaultCustomDomainResponseContent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// ID of the custom domain. + /// + [JsonPropertyName("custom_domain_id")] + public required string CustomDomainId { get; set; } + + /// + /// Domain name. + /// + [JsonPropertyName("domain")] + public required string Domain { get; set; } + + /// + /// Whether this is a primary domain (true) or not (false). + /// + [JsonPropertyName("primary")] + public required bool Primary { get; set; } + + /// + /// Whether this is the default custom domain (true) or not (false). + /// + [Optional] + [JsonPropertyName("is_default")] + public bool? IsDefault { get; set; } + + [JsonPropertyName("status")] + public required CustomDomainStatusFilterEnum Status { get; set; } + + [JsonPropertyName("type")] + public required CustomDomainTypeEnum Type { get; set; } + + /// + /// Intermediate address. + /// + [Optional] + [JsonPropertyName("origin_domain_name")] + public string? OriginDomainName { get; set; } + + [Optional] + [JsonPropertyName("verification")] + public DomainVerification? Verification { get; set; } + + /// + /// The HTTP header to fetch the client's IP address + /// + [Nullable, Optional] + [JsonPropertyName("custom_client_ip_header")] + public Optional CustomClientIpHeader { get; set; } + + /// + /// The TLS version policy + /// + [Optional] + [JsonPropertyName("tls_policy")] + public string? TlsPolicy { get; set; } + + [Optional] + [JsonPropertyName("domain_metadata")] + public Dictionary? DomainMetadata { get; set; } + + [Optional] + [JsonPropertyName("certificate")] + public DomainCertificate? Certificate { get; set; } + + /// + /// Relying Party ID (rpId) to be used for Passkeys on this custom domain. If not present, the full domain will be used. + /// + [Optional] + [JsonPropertyName("relying_party_identifier")] + public string? RelyingPartyIdentifier { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/GetDefaultDomainResponseContent.cs b/src/Auth0.ManagementApi/Types/GetDefaultDomainResponseContent.cs new file mode 100644 index 000000000..b49321150 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/GetDefaultDomainResponseContent.cs @@ -0,0 +1,290 @@ +// ReSharper disable NullableWarningSuppressionIsUsed +// ReSharper disable InconsistentNaming + +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter(typeof(GetDefaultDomainResponseContent.JsonConverter))] +[Serializable] +public class GetDefaultDomainResponseContent +{ + private GetDefaultDomainResponseContent(string type, object? value) + { + Type = type; + Value = value; + } + + /// + /// Type discriminator + /// + [JsonIgnore] + public string Type { get; internal set; } + + /// + /// Union value + /// + [JsonIgnore] + public object? Value { get; internal set; } + + /// + /// Factory method to create a union from a Auth0.ManagementApi.GetDefaultCustomDomainResponseContent value. + /// + public static GetDefaultDomainResponseContent FromGetDefaultCustomDomainResponseContent( + Auth0.ManagementApi.GetDefaultCustomDomainResponseContent value + ) => new("getDefaultCustomDomainResponseContent", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent value. + /// + public static GetDefaultDomainResponseContent FromGetDefaultCanonicalDomainResponseContent( + Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent value + ) => new("getDefaultCanonicalDomainResponseContent", value); + + /// + /// Returns true if is "getDefaultCustomDomainResponseContent" + /// + public bool IsGetDefaultCustomDomainResponseContent() => + Type == "getDefaultCustomDomainResponseContent"; + + /// + /// Returns true if is "getDefaultCanonicalDomainResponseContent" + /// + public bool IsGetDefaultCanonicalDomainResponseContent() => + Type == "getDefaultCanonicalDomainResponseContent"; + + /// + /// Returns the value as a if is 'getDefaultCustomDomainResponseContent', otherwise throws an exception. + /// + /// Thrown when is not 'getDefaultCustomDomainResponseContent'. + public Auth0.ManagementApi.GetDefaultCustomDomainResponseContent AsGetDefaultCustomDomainResponseContent() => + IsGetDefaultCustomDomainResponseContent() + ? (Auth0.ManagementApi.GetDefaultCustomDomainResponseContent)Value! + : throw new ManagementException( + "Union type is not 'getDefaultCustomDomainResponseContent'" + ); + + /// + /// Returns the value as a if is 'getDefaultCanonicalDomainResponseContent', otherwise throws an exception. + /// + /// Thrown when is not 'getDefaultCanonicalDomainResponseContent'. + public Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent AsGetDefaultCanonicalDomainResponseContent() => + IsGetDefaultCanonicalDomainResponseContent() + ? (Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent)Value! + : throw new ManagementException( + "Union type is not 'getDefaultCanonicalDomainResponseContent'" + ); + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetGetDefaultCustomDomainResponseContent( + out Auth0.ManagementApi.GetDefaultCustomDomainResponseContent? value + ) + { + if (Type == "getDefaultCustomDomainResponseContent") + { + value = (Auth0.ManagementApi.GetDefaultCustomDomainResponseContent)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetGetDefaultCanonicalDomainResponseContent( + out Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent? value + ) + { + if (Type == "getDefaultCanonicalDomainResponseContent") + { + value = (Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent)Value!; + return true; + } + value = null; + return false; + } + + public T Match( + Func< + Auth0.ManagementApi.GetDefaultCustomDomainResponseContent, + T + > onGetDefaultCustomDomainResponseContent, + Func< + Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent, + T + > onGetDefaultCanonicalDomainResponseContent + ) + { + return Type switch + { + "getDefaultCustomDomainResponseContent" => onGetDefaultCustomDomainResponseContent( + AsGetDefaultCustomDomainResponseContent() + ), + "getDefaultCanonicalDomainResponseContent" => + onGetDefaultCanonicalDomainResponseContent( + AsGetDefaultCanonicalDomainResponseContent() + ), + _ => throw new ManagementException($"Unknown union type: {Type}"), + }; + } + + public void Visit( + global::System.Action onGetDefaultCustomDomainResponseContent, + global::System.Action onGetDefaultCanonicalDomainResponseContent + ) + { + switch (Type) + { + case "getDefaultCustomDomainResponseContent": + onGetDefaultCustomDomainResponseContent(AsGetDefaultCustomDomainResponseContent()); + break; + case "getDefaultCanonicalDomainResponseContent": + onGetDefaultCanonicalDomainResponseContent( + AsGetDefaultCanonicalDomainResponseContent() + ); + break; + default: + throw new ManagementException($"Unknown union type: {Type}"); + } + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Type.GetHashCode(); + if (Value != null) + { + hashCode = (hashCode * 397) ^ Value.GetHashCode(); + } + return hashCode; + } + } + + public override bool Equals(object? obj) + { + if (obj is null) + return false; + if (ReferenceEquals(this, obj)) + return true; + if (obj is not GetDefaultDomainResponseContent other) + return false; + + // Compare type discriminators + if (Type != other.Type) + return false; + + // Compare values using EqualityComparer for deep comparison + return System.Collections.Generic.EqualityComparer.Default.Equals( + Value, + other.Value + ); + } + + public override string ToString() => JsonUtils.Serialize(this); + + public static implicit operator GetDefaultDomainResponseContent( + Auth0.ManagementApi.GetDefaultCustomDomainResponseContent value + ) => new("getDefaultCustomDomainResponseContent", value); + + public static implicit operator GetDefaultDomainResponseContent( + Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent value + ) => new("getDefaultCanonicalDomainResponseContent", value); + + [Serializable] + internal sealed class JsonConverter : JsonConverter + { + public override GetDefaultDomainResponseContent? Read( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + if (reader.TokenType == JsonTokenType.Null) + { + return null; + } + + if (reader.TokenType == JsonTokenType.StartObject) + { + var document = JsonDocument.ParseValue(ref reader); + + var types = new (string Key, System.Type Type)[] + { + ( + "getDefaultCustomDomainResponseContent", + typeof(Auth0.ManagementApi.GetDefaultCustomDomainResponseContent) + ), + ( + "getDefaultCanonicalDomainResponseContent", + typeof(Auth0.ManagementApi.GetDefaultCanonicalDomainResponseContent) + ), + }; + + foreach (var (key, type) in types) + { + try + { + var value = document.Deserialize(type, options); + if (value != null) + { + GetDefaultDomainResponseContent result = new(key, value); + return result; + } + } + catch (JsonException) + { + // Try next type; + } + } + } + + throw new JsonException( + $"Cannot deserialize JSON token {reader.TokenType} into GetDefaultDomainResponseContent" + ); + } + + public override void Write( + Utf8JsonWriter writer, + GetDefaultDomainResponseContent value, + JsonSerializerOptions options + ) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + + value.Visit( + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options) + ); + } + + public override GetDefaultDomainResponseContent ReadAsPropertyName( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = reader.GetString()!; + GetDefaultDomainResponseContent result = new("string", stringValue); + return result; + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + GetDefaultDomainResponseContent value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value?.ToString() ?? "null"); + } + } +} diff --git a/src/Auth0.ManagementApi/Types/GetDirectoryProvisioningResponseContent.cs b/src/Auth0.ManagementApi/Types/GetDirectoryProvisioningResponseContent.cs index 20eab6cd6..01179dcdb 100644 --- a/src/Auth0.ManagementApi/Types/GetDirectoryProvisioningResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/GetDirectoryProvisioningResponseContent.cs @@ -44,7 +44,7 @@ public record GetDirectoryProvisioningResponseContent : IJsonOnDeserialized [Optional] [JsonPropertyName("synchronize_groups")] - public string? SynchronizeGroups { get; set; } + public SynchronizeGroupsEnum? SynchronizeGroups { get; set; } /// /// The timestamp at which the directory provisioning configuration was created diff --git a/src/Auth0.ManagementApi/Types/GetOrganizationAllConnectionResponseContent.cs b/src/Auth0.ManagementApi/Types/GetOrganizationAllConnectionResponseContent.cs new file mode 100644 index 000000000..abf54b350 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/GetOrganizationAllConnectionResponseContent.cs @@ -0,0 +1,74 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record GetOrganizationAllConnectionResponseContent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Name of the connection in the scope of this organization. + /// + [Optional] + [JsonPropertyName("organization_connection_name")] + public string? OrganizationConnectionName { get; set; } + + /// + /// When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection. + /// + [Optional] + [JsonPropertyName("assign_membership_on_login")] + public bool? AssignMembershipOnLogin { get; set; } + + /// + /// Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + /// + /// Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. + /// + [Optional] + [JsonPropertyName("is_signup_enabled")] + public bool? IsSignupEnabled { get; set; } + + [Optional] + [JsonPropertyName("organization_access_level")] + public OrganizationAccessLevelEnum? OrganizationAccessLevel { get; set; } + + /// + /// Whether the connection is enabled for the organization. + /// + [Optional] + [JsonPropertyName("is_enabled")] + public bool? IsEnabled { get; set; } + + /// + /// Connection identifier. + /// + [JsonPropertyName("connection_id")] + public required string ConnectionId { get; set; } + + [Optional] + [JsonPropertyName("connection")] + public OrganizationConnectionInformation? Connection { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/GetRefreshTokensPaginatedResponseContent.cs b/src/Auth0.ManagementApi/Types/GetRefreshTokensPaginatedResponseContent.cs new file mode 100644 index 000000000..d0b3dbb15 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/GetRefreshTokensPaginatedResponseContent.cs @@ -0,0 +1,38 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record GetRefreshTokensPaginatedResponseContent : IJsonOnDeserialized, IJsonOnSerializing +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("refresh_tokens")] + public IEnumerable? RefreshTokens { get; set; } + + /// + /// A cursor to be used as the "from" query parameter for the next page of results. + /// + [Optional] + [JsonPropertyName("next")] + public string? Next { get; set; } + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + void IJsonOnSerializing.OnSerializing() => + AdditionalProperties.CopyToExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/IdentityProviderEnum.cs b/src/Auth0.ManagementApi/Types/IdentityProviderEnum.cs index b41416df8..7f5264099 100644 --- a/src/Auth0.ManagementApi/Types/IdentityProviderEnum.cs +++ b/src/Auth0.ManagementApi/Types/IdentityProviderEnum.cs @@ -20,8 +20,6 @@ namespace Auth0.ManagementApi; public static readonly IdentityProviderEnum Bitbucket = new(Values.Bitbucket); - public static readonly IdentityProviderEnum Aol = new(Values.Aol); - public static readonly IdentityProviderEnum Auth0Oidc = new(Values.Auth0Oidc); public static readonly IdentityProviderEnum Auth0 = new(Values.Auth0); @@ -50,8 +48,6 @@ namespace Auth0.ManagementApi; public static readonly IdentityProviderEnum Fitbit = new(Values.Fitbit); - public static readonly IdentityProviderEnum Flickr = new(Values.Flickr); - public static readonly IdentityProviderEnum Github = new(Values.Github); public static readonly IdentityProviderEnum GoogleApps = new(Values.GoogleApps); @@ -232,8 +228,6 @@ public static class Values public const string Bitbucket = "bitbucket"; - public const string Aol = "aol"; - public const string Auth0Oidc = "auth0-oidc"; public const string Auth0 = "auth0"; @@ -262,8 +256,6 @@ public static class Values public const string Fitbit = "fitbit"; - public const string Flickr = "flickr"; - public const string Github = "github"; public const string GoogleApps = "google-apps"; diff --git a/src/Auth0.ManagementApi/Types/UpdateConnectionRequestContentAol.cs b/src/Auth0.ManagementApi/Types/ListOrganizationAllConnectionsOffsetPaginatedResponseContent.cs similarity index 53% rename from src/Auth0.ManagementApi/Types/UpdateConnectionRequestContentAol.cs rename to src/Auth0.ManagementApi/Types/ListOrganizationAllConnectionsOffsetPaginatedResponseContent.cs index 3775a4c98..98cd4065e 100644 --- a/src/Auth0.ManagementApi/Types/UpdateConnectionRequestContentAol.cs +++ b/src/Auth0.ManagementApi/Types/ListOrganizationAllConnectionsOffsetPaginatedResponseContent.cs @@ -4,35 +4,28 @@ namespace Auth0.ManagementApi; -/// -/// Update a connection with strategy=aol -/// [Serializable] -public record UpdateConnectionRequestContentAol : IJsonOnDeserialized +public record ListOrganizationAllConnectionsOffsetPaginatedResponseContent : IJsonOnDeserialized { [JsonExtensionData] private readonly IDictionary _extensionData = new Dictionary(); [Optional] - [JsonPropertyName("options")] - public ConnectionOptionsAol? Options { get; set; } + [JsonPropertyName("start")] + public double? Start { get; set; } [Optional] - [JsonPropertyName("display_name")] - public string? DisplayName { get; set; } + [JsonPropertyName("limit")] + public double? Limit { get; set; } [Optional] - [JsonPropertyName("enabled_clients")] - public IEnumerable? EnabledClients { get; set; } + [JsonPropertyName("total")] + public double? Total { get; set; } [Optional] - [JsonPropertyName("is_domain_connection")] - public bool? IsDomainConnection { get; set; } - - [Optional] - [JsonPropertyName("metadata")] - public Dictionary? Metadata { get; set; } + [JsonPropertyName("connections")] + public IEnumerable? Connections { get; set; } [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/NetworkAclMatch.cs b/src/Auth0.ManagementApi/Types/NetworkAclMatch.cs index 4cc6c2653..2d914e27a 100644 --- a/src/Auth0.ManagementApi/Types/NetworkAclMatch.cs +++ b/src/Auth0.ManagementApi/Types/NetworkAclMatch.cs @@ -47,6 +47,18 @@ public record NetworkAclMatch : IJsonOnDeserialized [JsonPropertyName("user_agents")] public IEnumerable? UserAgents { get; set; } + [Optional] + [JsonPropertyName("hostnames")] + public IEnumerable? Hostnames { get; set; } + + [Optional] + [JsonPropertyName("connecting_ipv4_cidrs")] + public IEnumerable? ConnectingIpv4Cidrs { get; set; } + + [Optional] + [JsonPropertyName("connecting_ipv6_cidrs")] + public IEnumerable? ConnectingIpv6Cidrs { get; set; } + [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentAolStrategy.cs b/src/Auth0.ManagementApi/Types/OrganizationAccessLevelEnum.cs similarity index 52% rename from src/Auth0.ManagementApi/Types/CreateConnectionRequestContentAolStrategy.cs rename to src/Auth0.ManagementApi/Types/OrganizationAccessLevelEnum.cs index 272b702d7..4ee2ea80e 100644 --- a/src/Auth0.ManagementApi/Types/CreateConnectionRequestContentAolStrategy.cs +++ b/src/Auth0.ManagementApi/Types/OrganizationAccessLevelEnum.cs @@ -4,15 +4,19 @@ namespace Auth0.ManagementApi; -[JsonConverter( - typeof(CreateConnectionRequestContentAolStrategy.CreateConnectionRequestContentAolStrategySerializer) -)] +[JsonConverter(typeof(OrganizationAccessLevelEnum.OrganizationAccessLevelEnumSerializer))] [Serializable] -public readonly record struct CreateConnectionRequestContentAolStrategy : IStringEnum +public readonly record struct OrganizationAccessLevelEnum : IStringEnum { - public static readonly CreateConnectionRequestContentAolStrategy Aol = new(Values.Aol); + public static readonly OrganizationAccessLevelEnum None = new(Values.None); - public CreateConnectionRequestContentAolStrategy(string value) + public static readonly OrganizationAccessLevelEnum Readonly = new(Values.Readonly); + + public static readonly OrganizationAccessLevelEnum Limited = new(Values.Limited); + + public static readonly OrganizationAccessLevelEnum Full = new(Values.Full); + + public OrganizationAccessLevelEnum(string value) { Value = value; } @@ -25,9 +29,9 @@ public CreateConnectionRequestContentAolStrategy(string value) /// /// Create a string enum with the given value. /// - public static CreateConnectionRequestContentAolStrategy FromCustom(string value) + public static OrganizationAccessLevelEnum FromCustom(string value) { - return new CreateConnectionRequestContentAolStrategy(value); + return new OrganizationAccessLevelEnum(value); } public bool Equals(string? other) @@ -43,26 +47,20 @@ public override string ToString() return Value; } - public static bool operator ==( - CreateConnectionRequestContentAolStrategy value1, - string value2 - ) => value1.Value.Equals(value2); + public static bool operator ==(OrganizationAccessLevelEnum value1, string value2) => + value1.Value.Equals(value2); - public static bool operator !=( - CreateConnectionRequestContentAolStrategy value1, - string value2 - ) => !value1.Value.Equals(value2); + public static bool operator !=(OrganizationAccessLevelEnum value1, string value2) => + !value1.Value.Equals(value2); - public static explicit operator string(CreateConnectionRequestContentAolStrategy value) => - value.Value; + public static explicit operator string(OrganizationAccessLevelEnum value) => value.Value; - public static explicit operator CreateConnectionRequestContentAolStrategy(string value) => - new(value); + public static explicit operator OrganizationAccessLevelEnum(string value) => new(value); - internal class CreateConnectionRequestContentAolStrategySerializer - : JsonConverter + internal class OrganizationAccessLevelEnumSerializer + : JsonConverter { - public override CreateConnectionRequestContentAolStrategy Read( + public override OrganizationAccessLevelEnum Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -73,19 +71,19 @@ JsonSerializerOptions options ?? throw new global::System.Exception( "The JSON value could not be read as a string." ); - return new CreateConnectionRequestContentAolStrategy(stringValue); + return new OrganizationAccessLevelEnum(stringValue); } public override void Write( Utf8JsonWriter writer, - CreateConnectionRequestContentAolStrategy value, + OrganizationAccessLevelEnum value, JsonSerializerOptions options ) { writer.WriteStringValue(value.Value); } - public override CreateConnectionRequestContentAolStrategy ReadAsPropertyName( + public override OrganizationAccessLevelEnum ReadAsPropertyName( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -96,12 +94,12 @@ JsonSerializerOptions options ?? throw new global::System.Exception( "The JSON property name could not be read as a string." ); - return new CreateConnectionRequestContentAolStrategy(stringValue); + return new OrganizationAccessLevelEnum(stringValue); } public override void WriteAsPropertyName( Utf8JsonWriter writer, - CreateConnectionRequestContentAolStrategy value, + OrganizationAccessLevelEnum value, JsonSerializerOptions options ) { @@ -115,6 +113,12 @@ JsonSerializerOptions options [Serializable] public static class Values { - public const string Aol = "aol"; + public const string None = "none"; + + public const string Readonly = "readonly"; + + public const string Limited = "limited"; + + public const string Full = "full"; } } diff --git a/src/Auth0.ManagementApi/Types/OrganizationAccessLevelEnumWithNull.cs b/src/Auth0.ManagementApi/Types/OrganizationAccessLevelEnumWithNull.cs new file mode 100644 index 000000000..3548518db --- /dev/null +++ b/src/Auth0.ManagementApi/Types/OrganizationAccessLevelEnumWithNull.cs @@ -0,0 +1,127 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(OrganizationAccessLevelEnumWithNull.OrganizationAccessLevelEnumWithNullSerializer) +)] +[Serializable] +public readonly record struct OrganizationAccessLevelEnumWithNull : IStringEnum +{ + public static readonly OrganizationAccessLevelEnumWithNull None = new(Values.None); + + public static readonly OrganizationAccessLevelEnumWithNull Readonly = new(Values.Readonly); + + public static readonly OrganizationAccessLevelEnumWithNull Limited = new(Values.Limited); + + public static readonly OrganizationAccessLevelEnumWithNull Full = new(Values.Full); + + public OrganizationAccessLevelEnumWithNull(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static OrganizationAccessLevelEnumWithNull FromCustom(string value) + { + return new OrganizationAccessLevelEnumWithNull(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(OrganizationAccessLevelEnumWithNull value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(OrganizationAccessLevelEnumWithNull value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(OrganizationAccessLevelEnumWithNull value) => + value.Value; + + public static explicit operator OrganizationAccessLevelEnumWithNull(string value) => new(value); + + internal class OrganizationAccessLevelEnumWithNullSerializer + : JsonConverter + { + public override OrganizationAccessLevelEnumWithNull Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new OrganizationAccessLevelEnumWithNull(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + OrganizationAccessLevelEnumWithNull value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override OrganizationAccessLevelEnumWithNull ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new OrganizationAccessLevelEnumWithNull(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + OrganizationAccessLevelEnumWithNull value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string None = "none"; + + public const string Readonly = "readonly"; + + public const string Limited = "limited"; + + public const string Full = "full"; + } +} diff --git a/src/Auth0.ManagementApi/Types/OrganizationAllConnectionPost.cs b/src/Auth0.ManagementApi/Types/OrganizationAllConnectionPost.cs new file mode 100644 index 000000000..fcd429b50 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/OrganizationAllConnectionPost.cs @@ -0,0 +1,74 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record OrganizationAllConnectionPost : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Name of the connection in the scope of this organization. + /// + [Optional] + [JsonPropertyName("organization_connection_name")] + public string? OrganizationConnectionName { get; set; } + + /// + /// When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection. + /// + [Optional] + [JsonPropertyName("assign_membership_on_login")] + public bool? AssignMembershipOnLogin { get; set; } + + /// + /// Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + /// + /// Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. + /// + [Optional] + [JsonPropertyName("is_signup_enabled")] + public bool? IsSignupEnabled { get; set; } + + [Optional] + [JsonPropertyName("organization_access_level")] + public OrganizationAccessLevelEnum? OrganizationAccessLevel { get; set; } + + /// + /// Whether the connection is enabled for the organization. + /// + [Optional] + [JsonPropertyName("is_enabled")] + public bool? IsEnabled { get; set; } + + /// + /// Connection identifier. + /// + [JsonPropertyName("connection_id")] + public required string ConnectionId { get; set; } + + [Optional] + [JsonPropertyName("connection")] + public OrganizationConnectionInformation? Connection { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/ConnectionOptionsAol.cs b/src/Auth0.ManagementApi/Types/PreviewCimdMetadataResponseContent.cs similarity index 52% rename from src/Auth0.ManagementApi/Types/ConnectionOptionsAol.cs rename to src/Auth0.ManagementApi/Types/PreviewCimdMetadataResponseContent.cs index 60ab02fcb..91baf536b 100644 --- a/src/Auth0.ManagementApi/Types/ConnectionOptionsAol.cs +++ b/src/Auth0.ManagementApi/Types/PreviewCimdMetadataResponseContent.cs @@ -3,42 +3,34 @@ namespace Auth0.ManagementApi; -/// -/// Options for the 'aol' connection -/// [Serializable] -public record ConnectionOptionsAol : IJsonOnDeserialized, IJsonOnSerializing +public record PreviewCimdMetadataResponseContent : IJsonOnDeserialized, IJsonOnSerializing { [JsonExtensionData] private readonly IDictionary _extensionData = new Dictionary(); + /// + /// The client_id of an existing client registered with this external_client_id, if one exists. + /// [Optional] [JsonPropertyName("client_id")] public string? ClientId { get; set; } + /// + /// Array of retrieval errors (populated when the metadata document could not be fetched). When present, validation is omitted. + /// [Optional] - [JsonPropertyName("client_secret")] - public string? ClientSecret { get; set; } + [JsonPropertyName("errors")] + public IEnumerable? Errors { get; set; } [Optional] - [JsonPropertyName("scope")] - public ConnectionScopeOAuth2? Scope { get; set; } + [JsonPropertyName("validation")] + public CimdValidationResult? Validation { get; set; } [Optional] - [JsonPropertyName("set_user_root_attributes")] - public ConnectionSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } - - [Nullable, Optional] - [JsonPropertyName("upstream_params")] - public Optional?> UpstreamParams { get; set; } - - [Optional] - [JsonPropertyName("non_persistent_attrs")] - public IEnumerable? NonPersistentAttrs { get; set; } + [JsonPropertyName("mapped_fields")] + public CimdMappedClientFields? MappedFields { get; set; } [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/RegisterCimdClientResponseContent.cs b/src/Auth0.ManagementApi/Types/RegisterCimdClientResponseContent.cs new file mode 100644 index 000000000..9ff71f73d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/RegisterCimdClientResponseContent.cs @@ -0,0 +1,42 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Response after successfully registering or updating a CIMD client +/// +[Serializable] +public record RegisterCimdClientResponseContent : IJsonOnDeserialized, IJsonOnSerializing +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The Auth0 client_id of the created or updated client + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + [JsonPropertyName("mapped_fields")] + public required CimdMappedClientFields MappedFields { get; set; } + + [JsonPropertyName("validation")] + public required CimdValidationResult Validation { get; set; } + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + void IJsonOnSerializing.OnSerializing() => + AdditionalProperties.CopyToExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/RotateClientSecretResponseContent.cs b/src/Auth0.ManagementApi/Types/RotateClientSecretResponseContent.cs index 7905e1c1e..a4022ad65 100644 --- a/src/Auth0.ManagementApi/Types/RotateClientSecretResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/RotateClientSecretResponseContent.cs @@ -320,6 +320,28 @@ public record RotateClientSecretResponseContent : IJsonOnDeserialized, IJsonOnSe [JsonPropertyName("async_approval_notification_channels")] public IEnumerable? AsyncApprovalNotificationChannels { get; set; } + [Optional] + [JsonPropertyName("external_metadata_type")] + public ClientExternalMetadataTypeEnum? ExternalMetadataType { get; set; } + + [Optional] + [JsonPropertyName("external_metadata_created_by")] + public ClientExternalMetadataCreatedByEnum? ExternalMetadataCreatedBy { get; set; } + + /// + /// An alternate client identifier to be used during authorization flows. Only supports CIMD-based client identifiers. + /// + [Optional] + [JsonPropertyName("external_client_id")] + public string? ExternalClientId { get; set; } + + /// + /// URL for the JSON Web Key Set (JWKS) containing the public keys used for private_key_jwt authentication. Only present for CIMD clients using private_key_jwt authentication. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/SynchronizeGroupsEaEnum.cs b/src/Auth0.ManagementApi/Types/SynchronizeGroupsEnum.cs similarity index 62% rename from src/Auth0.ManagementApi/Types/SynchronizeGroupsEaEnum.cs rename to src/Auth0.ManagementApi/Types/SynchronizeGroupsEnum.cs index 782904355..cc5edfb41 100644 --- a/src/Auth0.ManagementApi/Types/SynchronizeGroupsEaEnum.cs +++ b/src/Auth0.ManagementApi/Types/SynchronizeGroupsEnum.cs @@ -4,15 +4,15 @@ namespace Auth0.ManagementApi; -[JsonConverter(typeof(SynchronizeGroupsEaEnum.SynchronizeGroupsEaEnumSerializer))] +[JsonConverter(typeof(SynchronizeGroupsEnum.SynchronizeGroupsEnumSerializer))] [Serializable] -public readonly record struct SynchronizeGroupsEaEnum : IStringEnum +public readonly record struct SynchronizeGroupsEnum : IStringEnum { - public static readonly SynchronizeGroupsEaEnum All = new(Values.All); + public static readonly SynchronizeGroupsEnum All = new(Values.All); - public static readonly SynchronizeGroupsEaEnum Off = new(Values.Off); + public static readonly SynchronizeGroupsEnum Off = new(Values.Off); - public SynchronizeGroupsEaEnum(string value) + public SynchronizeGroupsEnum(string value) { Value = value; } @@ -25,9 +25,9 @@ public SynchronizeGroupsEaEnum(string value) /// /// Create a string enum with the given value. /// - public static SynchronizeGroupsEaEnum FromCustom(string value) + public static SynchronizeGroupsEnum FromCustom(string value) { - return new SynchronizeGroupsEaEnum(value); + return new SynchronizeGroupsEnum(value); } public bool Equals(string? other) @@ -43,19 +43,19 @@ public override string ToString() return Value; } - public static bool operator ==(SynchronizeGroupsEaEnum value1, string value2) => + public static bool operator ==(SynchronizeGroupsEnum value1, string value2) => value1.Value.Equals(value2); - public static bool operator !=(SynchronizeGroupsEaEnum value1, string value2) => + public static bool operator !=(SynchronizeGroupsEnum value1, string value2) => !value1.Value.Equals(value2); - public static explicit operator string(SynchronizeGroupsEaEnum value) => value.Value; + public static explicit operator string(SynchronizeGroupsEnum value) => value.Value; - public static explicit operator SynchronizeGroupsEaEnum(string value) => new(value); + public static explicit operator SynchronizeGroupsEnum(string value) => new(value); - internal class SynchronizeGroupsEaEnumSerializer : JsonConverter + internal class SynchronizeGroupsEnumSerializer : JsonConverter { - public override SynchronizeGroupsEaEnum Read( + public override SynchronizeGroupsEnum Read( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -66,19 +66,19 @@ JsonSerializerOptions options ?? throw new global::System.Exception( "The JSON value could not be read as a string." ); - return new SynchronizeGroupsEaEnum(stringValue); + return new SynchronizeGroupsEnum(stringValue); } public override void Write( Utf8JsonWriter writer, - SynchronizeGroupsEaEnum value, + SynchronizeGroupsEnum value, JsonSerializerOptions options ) { writer.WriteStringValue(value.Value); } - public override SynchronizeGroupsEaEnum ReadAsPropertyName( + public override SynchronizeGroupsEnum ReadAsPropertyName( ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options @@ -89,12 +89,12 @@ JsonSerializerOptions options ?? throw new global::System.Exception( "The JSON property name could not be read as a string." ); - return new SynchronizeGroupsEaEnum(stringValue); + return new SynchronizeGroupsEnum(stringValue); } public override void WriteAsPropertyName( Utf8JsonWriter writer, - SynchronizeGroupsEaEnum value, + SynchronizeGroupsEnum value, JsonSerializerOptions options ) { diff --git a/src/Auth0.ManagementApi/Types/UpdateClientResponseContent.cs b/src/Auth0.ManagementApi/Types/UpdateClientResponseContent.cs index 861d49ae5..1a2a25d70 100644 --- a/src/Auth0.ManagementApi/Types/UpdateClientResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/UpdateClientResponseContent.cs @@ -320,6 +320,28 @@ public record UpdateClientResponseContent : IJsonOnDeserialized, IJsonOnSerializ [JsonPropertyName("async_approval_notification_channels")] public IEnumerable? AsyncApprovalNotificationChannels { get; set; } + [Optional] + [JsonPropertyName("external_metadata_type")] + public ClientExternalMetadataTypeEnum? ExternalMetadataType { get; set; } + + [Optional] + [JsonPropertyName("external_metadata_created_by")] + public ClientExternalMetadataCreatedByEnum? ExternalMetadataCreatedBy { get; set; } + + /// + /// An alternate client identifier to be used during authorization flows. Only supports CIMD-based client identifiers. + /// + [Optional] + [JsonPropertyName("external_client_id")] + public string? ExternalClientId { get; set; } + + /// + /// URL for the JSON Web Key Set (JWKS) containing the public keys used for private_key_jwt authentication. Only present for CIMD clients using private_key_jwt authentication. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/UpdateConnectionRequestContentFlickr.cs b/src/Auth0.ManagementApi/Types/UpdateConnectionRequestContentFlickr.cs deleted file mode 100644 index c5ace6747..000000000 --- a/src/Auth0.ManagementApi/Types/UpdateConnectionRequestContentFlickr.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Auth0.ManagementApi.Core; -using global::System.Text.Json; -using global::System.Text.Json.Serialization; - -namespace Auth0.ManagementApi; - -/// -/// Update a connection with strategy=flickr -/// -[Serializable] -public record UpdateConnectionRequestContentFlickr : IJsonOnDeserialized -{ - [JsonExtensionData] - private readonly IDictionary _extensionData = - new Dictionary(); - - [Optional] - [JsonPropertyName("options")] - public ConnectionOptionsFlickr? Options { get; set; } - - [Optional] - [JsonPropertyName("display_name")] - public string? DisplayName { get; set; } - - [Optional] - [JsonPropertyName("enabled_clients")] - public IEnumerable? EnabledClients { get; set; } - - [Optional] - [JsonPropertyName("is_domain_connection")] - public bool? IsDomainConnection { get; set; } - - [Optional] - [JsonPropertyName("metadata")] - public Dictionary? Metadata { get; set; } - - [JsonIgnore] - public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); - - void IJsonOnDeserialized.OnDeserialized() => - AdditionalProperties.CopyFromExtensionData(_extensionData); - - /// - public override string ToString() - { - return JsonUtils.Serialize(this); - } -} diff --git a/src/Auth0.ManagementApi/Types/UpdateDefaultCanonicalDomainResponseContent.cs b/src/Auth0.ManagementApi/Types/UpdateDefaultCanonicalDomainResponseContent.cs new file mode 100644 index 000000000..642cacc7c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/UpdateDefaultCanonicalDomainResponseContent.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record UpdateDefaultCanonicalDomainResponseContent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Domain name. + /// + [JsonPropertyName("domain")] + public required string Domain { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/UpdateDefaultCustomDomainResponseContent.cs b/src/Auth0.ManagementApi/Types/UpdateDefaultCustomDomainResponseContent.cs new file mode 100644 index 000000000..917bcec46 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/UpdateDefaultCustomDomainResponseContent.cs @@ -0,0 +1,96 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record UpdateDefaultCustomDomainResponseContent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// ID of the custom domain. + /// + [JsonPropertyName("custom_domain_id")] + public required string CustomDomainId { get; set; } + + /// + /// Domain name. + /// + [JsonPropertyName("domain")] + public required string Domain { get; set; } + + /// + /// Whether this is a primary domain (true) or not (false). + /// + [JsonPropertyName("primary")] + public required bool Primary { get; set; } + + /// + /// Whether this is the default custom domain (true) or not (false). + /// + [Optional] + [JsonPropertyName("is_default")] + public bool? IsDefault { get; set; } + + [JsonPropertyName("status")] + public required CustomDomainStatusFilterEnum Status { get; set; } + + [JsonPropertyName("type")] + public required CustomDomainTypeEnum Type { get; set; } + + /// + /// Intermediate address. + /// + [Optional] + [JsonPropertyName("origin_domain_name")] + public string? OriginDomainName { get; set; } + + [Optional] + [JsonPropertyName("verification")] + public DomainVerification? Verification { get; set; } + + /// + /// The HTTP header to fetch the client's IP address + /// + [Nullable, Optional] + [JsonPropertyName("custom_client_ip_header")] + public Optional CustomClientIpHeader { get; set; } + + /// + /// The TLS version policy + /// + [Optional] + [JsonPropertyName("tls_policy")] + public string? TlsPolicy { get; set; } + + [Optional] + [JsonPropertyName("domain_metadata")] + public Dictionary? DomainMetadata { get; set; } + + [Optional] + [JsonPropertyName("certificate")] + public DomainCertificate? Certificate { get; set; } + + /// + /// Relying Party ID (rpId) to be used for Passkeys on this custom domain. If not present, the full domain will be used. + /// + [Optional] + [JsonPropertyName("relying_party_identifier")] + public string? RelyingPartyIdentifier { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/UpdateDefaultDomainResponseContent.cs b/src/Auth0.ManagementApi/Types/UpdateDefaultDomainResponseContent.cs new file mode 100644 index 000000000..cef24c520 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/UpdateDefaultDomainResponseContent.cs @@ -0,0 +1,293 @@ +// ReSharper disable NullableWarningSuppressionIsUsed +// ReSharper disable InconsistentNaming + +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter(typeof(UpdateDefaultDomainResponseContent.JsonConverter))] +[Serializable] +public class UpdateDefaultDomainResponseContent +{ + private UpdateDefaultDomainResponseContent(string type, object? value) + { + Type = type; + Value = value; + } + + /// + /// Type discriminator + /// + [JsonIgnore] + public string Type { get; internal set; } + + /// + /// Union value + /// + [JsonIgnore] + public object? Value { get; internal set; } + + /// + /// Factory method to create a union from a Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent value. + /// + public static UpdateDefaultDomainResponseContent FromUpdateDefaultCustomDomainResponseContent( + Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent value + ) => new("updateDefaultCustomDomainResponseContent", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent value. + /// + public static UpdateDefaultDomainResponseContent FromUpdateDefaultCanonicalDomainResponseContent( + Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent value + ) => new("updateDefaultCanonicalDomainResponseContent", value); + + /// + /// Returns true if is "updateDefaultCustomDomainResponseContent" + /// + public bool IsUpdateDefaultCustomDomainResponseContent() => + Type == "updateDefaultCustomDomainResponseContent"; + + /// + /// Returns true if is "updateDefaultCanonicalDomainResponseContent" + /// + public bool IsUpdateDefaultCanonicalDomainResponseContent() => + Type == "updateDefaultCanonicalDomainResponseContent"; + + /// + /// Returns the value as a if is 'updateDefaultCustomDomainResponseContent', otherwise throws an exception. + /// + /// Thrown when is not 'updateDefaultCustomDomainResponseContent'. + public Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent AsUpdateDefaultCustomDomainResponseContent() => + IsUpdateDefaultCustomDomainResponseContent() + ? (Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent)Value! + : throw new ManagementException( + "Union type is not 'updateDefaultCustomDomainResponseContent'" + ); + + /// + /// Returns the value as a if is 'updateDefaultCanonicalDomainResponseContent', otherwise throws an exception. + /// + /// Thrown when is not 'updateDefaultCanonicalDomainResponseContent'. + public Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent AsUpdateDefaultCanonicalDomainResponseContent() => + IsUpdateDefaultCanonicalDomainResponseContent() + ? (Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent)Value! + : throw new ManagementException( + "Union type is not 'updateDefaultCanonicalDomainResponseContent'" + ); + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetUpdateDefaultCustomDomainResponseContent( + out Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent? value + ) + { + if (Type == "updateDefaultCustomDomainResponseContent") + { + value = (Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetUpdateDefaultCanonicalDomainResponseContent( + out Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent? value + ) + { + if (Type == "updateDefaultCanonicalDomainResponseContent") + { + value = (Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent)Value!; + return true; + } + value = null; + return false; + } + + public T Match( + Func< + Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent, + T + > onUpdateDefaultCustomDomainResponseContent, + Func< + Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent, + T + > onUpdateDefaultCanonicalDomainResponseContent + ) + { + return Type switch + { + "updateDefaultCustomDomainResponseContent" => + onUpdateDefaultCustomDomainResponseContent( + AsUpdateDefaultCustomDomainResponseContent() + ), + "updateDefaultCanonicalDomainResponseContent" => + onUpdateDefaultCanonicalDomainResponseContent( + AsUpdateDefaultCanonicalDomainResponseContent() + ), + _ => throw new ManagementException($"Unknown union type: {Type}"), + }; + } + + public void Visit( + global::System.Action onUpdateDefaultCustomDomainResponseContent, + global::System.Action onUpdateDefaultCanonicalDomainResponseContent + ) + { + switch (Type) + { + case "updateDefaultCustomDomainResponseContent": + onUpdateDefaultCustomDomainResponseContent( + AsUpdateDefaultCustomDomainResponseContent() + ); + break; + case "updateDefaultCanonicalDomainResponseContent": + onUpdateDefaultCanonicalDomainResponseContent( + AsUpdateDefaultCanonicalDomainResponseContent() + ); + break; + default: + throw new ManagementException($"Unknown union type: {Type}"); + } + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Type.GetHashCode(); + if (Value != null) + { + hashCode = (hashCode * 397) ^ Value.GetHashCode(); + } + return hashCode; + } + } + + public override bool Equals(object? obj) + { + if (obj is null) + return false; + if (ReferenceEquals(this, obj)) + return true; + if (obj is not UpdateDefaultDomainResponseContent other) + return false; + + // Compare type discriminators + if (Type != other.Type) + return false; + + // Compare values using EqualityComparer for deep comparison + return System.Collections.Generic.EqualityComparer.Default.Equals( + Value, + other.Value + ); + } + + public override string ToString() => JsonUtils.Serialize(this); + + public static implicit operator UpdateDefaultDomainResponseContent( + Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent value + ) => new("updateDefaultCustomDomainResponseContent", value); + + public static implicit operator UpdateDefaultDomainResponseContent( + Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent value + ) => new("updateDefaultCanonicalDomainResponseContent", value); + + [Serializable] + internal sealed class JsonConverter : JsonConverter + { + public override UpdateDefaultDomainResponseContent? Read( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + if (reader.TokenType == JsonTokenType.Null) + { + return null; + } + + if (reader.TokenType == JsonTokenType.StartObject) + { + var document = JsonDocument.ParseValue(ref reader); + + var types = new (string Key, System.Type Type)[] + { + ( + "updateDefaultCustomDomainResponseContent", + typeof(Auth0.ManagementApi.UpdateDefaultCustomDomainResponseContent) + ), + ( + "updateDefaultCanonicalDomainResponseContent", + typeof(Auth0.ManagementApi.UpdateDefaultCanonicalDomainResponseContent) + ), + }; + + foreach (var (key, type) in types) + { + try + { + var value = document.Deserialize(type, options); + if (value != null) + { + UpdateDefaultDomainResponseContent result = new(key, value); + return result; + } + } + catch (JsonException) + { + // Try next type; + } + } + } + + throw new JsonException( + $"Cannot deserialize JSON token {reader.TokenType} into UpdateDefaultDomainResponseContent" + ); + } + + public override void Write( + Utf8JsonWriter writer, + UpdateDefaultDomainResponseContent value, + JsonSerializerOptions options + ) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + + value.Visit( + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options) + ); + } + + public override UpdateDefaultDomainResponseContent ReadAsPropertyName( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = reader.GetString()!; + UpdateDefaultDomainResponseContent result = new("string", stringValue); + return result; + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + UpdateDefaultDomainResponseContent value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value?.ToString() ?? "null"); + } + } +} diff --git a/src/Auth0.ManagementApi/Types/UpdateDirectoryProvisioningRequestContent.cs b/src/Auth0.ManagementApi/Types/UpdateDirectoryProvisioningRequestContent.cs index d47970c97..f79a99bd8 100644 --- a/src/Auth0.ManagementApi/Types/UpdateDirectoryProvisioningRequestContent.cs +++ b/src/Auth0.ManagementApi/Types/UpdateDirectoryProvisioningRequestContent.cs @@ -27,7 +27,7 @@ public record UpdateDirectoryProvisioningRequestContent : IJsonOnDeserialized [Optional] [JsonPropertyName("synchronize_groups")] - public string? SynchronizeGroups { get; set; } + public SynchronizeGroupsEnum? SynchronizeGroups { get; set; } [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/UpdateDirectoryProvisioningResponseContent.cs b/src/Auth0.ManagementApi/Types/UpdateDirectoryProvisioningResponseContent.cs index 36ec5e6bd..d26c8ec71 100644 --- a/src/Auth0.ManagementApi/Types/UpdateDirectoryProvisioningResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/UpdateDirectoryProvisioningResponseContent.cs @@ -44,7 +44,7 @@ public record UpdateDirectoryProvisioningResponseContent : IJsonOnDeserialized [Optional] [JsonPropertyName("synchronize_groups")] - public string? SynchronizeGroups { get; set; } + public SynchronizeGroupsEnum? SynchronizeGroups { get; set; } /// /// The timestamp at which the directory provisioning configuration was created diff --git a/src/Auth0.ManagementApi/Types/UpdateOrganizationAllConnectionResponseContent.cs b/src/Auth0.ManagementApi/Types/UpdateOrganizationAllConnectionResponseContent.cs new file mode 100644 index 000000000..d75e4fd5f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/UpdateOrganizationAllConnectionResponseContent.cs @@ -0,0 +1,74 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record UpdateOrganizationAllConnectionResponseContent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Name of the connection in the scope of this organization. + /// + [Optional] + [JsonPropertyName("organization_connection_name")] + public string? OrganizationConnectionName { get; set; } + + /// + /// When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection. + /// + [Optional] + [JsonPropertyName("assign_membership_on_login")] + public bool? AssignMembershipOnLogin { get; set; } + + /// + /// Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + /// + /// Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. + /// + [Optional] + [JsonPropertyName("is_signup_enabled")] + public bool? IsSignupEnabled { get; set; } + + [Optional] + [JsonPropertyName("organization_access_level")] + public OrganizationAccessLevelEnum? OrganizationAccessLevel { get; set; } + + /// + /// Whether the connection is enabled for the organization. + /// + [Optional] + [JsonPropertyName("is_enabled")] + public bool? IsEnabled { get; set; } + + /// + /// Connection identifier. + /// + [JsonPropertyName("connection_id")] + public required string ConnectionId { get; set; } + + [Optional] + [JsonPropertyName("connection")] + public OrganizationConnectionInformation? Connection { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/UserIdentityProviderEnum.cs b/src/Auth0.ManagementApi/Types/UserIdentityProviderEnum.cs index 054a07bb0..d108d8e07 100644 --- a/src/Auth0.ManagementApi/Types/UserIdentityProviderEnum.cs +++ b/src/Auth0.ManagementApi/Types/UserIdentityProviderEnum.cs @@ -20,8 +20,6 @@ namespace Auth0.ManagementApi; public static readonly UserIdentityProviderEnum Bitbucket = new(Values.Bitbucket); - public static readonly UserIdentityProviderEnum Aol = new(Values.Aol); - public static readonly UserIdentityProviderEnum Auth0Oidc = new(Values.Auth0Oidc); public static readonly UserIdentityProviderEnum Auth0 = new(Values.Auth0); @@ -50,8 +48,6 @@ namespace Auth0.ManagementApi; public static readonly UserIdentityProviderEnum Fitbit = new(Values.Fitbit); - public static readonly UserIdentityProviderEnum Flickr = new(Values.Flickr); - public static readonly UserIdentityProviderEnum Github = new(Values.Github); public static readonly UserIdentityProviderEnum GoogleApps = new(Values.GoogleApps); @@ -236,8 +232,6 @@ public static class Values public const string Bitbucket = "bitbucket"; - public const string Aol = "aol"; - public const string Auth0Oidc = "auth0-oidc"; public const string Auth0 = "auth0"; @@ -266,8 +260,6 @@ public static class Values public const string Fitbit = "fitbit"; - public const string Flickr = "flickr"; - public const string Github = "github"; public const string GoogleApps = "google-apps"; diff --git a/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj b/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj index 7764da967..bb41e5fd8 100644 --- a/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj +++ b/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj @@ -1,6 +1,6 @@ - net10.0 + net9.0 12 enable enable diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/CreateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/CreateTest.cs index a3e19e532..77bedacf5 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/CreateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/CreateTest.cs @@ -366,7 +366,11 @@ public async Task MockServerTest() "resource_server_identifier": "resource_server_identifier", "async_approval_notification_channels": [ "guardian-push" - ] + ], + "external_metadata_type": "cimd", + "external_metadata_created_by": "admin", + "external_client_id": "external_client_id", + "jwks_uri": "jwks_uri" } """; diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/GetTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/GetTest.cs index c93cf8dbf..8888e5a47 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/GetTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/GetTest.cs @@ -360,7 +360,11 @@ public async Task MockServerTest() "resource_server_identifier": "resource_server_identifier", "async_approval_notification_channels": [ "guardian-push" - ] + ], + "external_metadata_type": "cimd", + "external_metadata_created_by": "admin", + "external_client_id": "external_client_id", + "jwks_uri": "jwks_uri" } """; diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/ListTest.cs index 410be0e3b..145a99e22 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/ListTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/ListTest.cs @@ -101,7 +101,11 @@ public async Task MockServerTest() "resource_server_identifier": "resource_server_identifier", "async_approval_notification_channels": [ "guardian-push" - ] + ], + "external_metadata_type": "cimd", + "external_metadata_created_by": "admin", + "external_client_id": "external_client_id", + "jwks_uri": "jwks_uri" } ] } diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/PreviewCimdMetadataTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/PreviewCimdMetadataTest.cs new file mode 100644 index 000000000..e6f5f9349 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/PreviewCimdMetadataTest.cs @@ -0,0 +1,86 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Test.Unit.MockServer; +using Auth0.ManagementApi.Test.Utils; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.Clients; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class PreviewCimdMetadataTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "external_client_id": "external_client_id" + } + """; + + const string mockResponse = """ + { + "client_id": "client_id", + "errors": [ + "errors" + ], + "validation": { + "valid": true, + "violations": [ + "violations" + ], + "warnings": [ + "warnings" + ] + }, + "mapped_fields": { + "external_client_id": "external_client_id", + "name": "name", + "app_type": "app_type", + "callbacks": [ + "callbacks" + ], + "logo_uri": "logo_uri", + "description": "description", + "grant_types": [ + "grant_types" + ], + "token_endpoint_auth_method": "token_endpoint_auth_method", + "jwks_uri": "jwks_uri", + "client_authentication_methods": { + "private_key_jwt": { + "credentials": [ + { + "credential_type": "credential_type", + "kid": "kid", + "alg": "alg" + } + ] + } + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/clients/cimd/preview") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Clients.PreviewCimdMetadataAsync( + new PreviewCimdMetadataRequestContent { ExternalClientId = "external_client_id" } + ); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RegisterCimdClientTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RegisterCimdClientTest.cs new file mode 100644 index 000000000..3b7ea53bf --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RegisterCimdClientTest.cs @@ -0,0 +1,83 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Test.Unit.MockServer; +using Auth0.ManagementApi.Test.Utils; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.Clients; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class RegisterCimdClientTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "external_client_id": "external_client_id" + } + """; + + const string mockResponse = """ + { + "client_id": "client_id", + "mapped_fields": { + "external_client_id": "external_client_id", + "name": "name", + "app_type": "app_type", + "callbacks": [ + "callbacks" + ], + "logo_uri": "logo_uri", + "description": "description", + "grant_types": [ + "grant_types" + ], + "token_endpoint_auth_method": "token_endpoint_auth_method", + "jwks_uri": "jwks_uri", + "client_authentication_methods": { + "private_key_jwt": { + "credentials": [ + { + "credential_type": "credential_type", + "kid": "kid", + "alg": "alg" + } + ] + } + } + }, + "validation": { + "valid": true, + "violations": [ + "violations" + ], + "warnings": [ + "warnings" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/clients/cimd/register") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Clients.RegisterCimdClientAsync( + new RegisterCimdClientRequestContent { ExternalClientId = "external_client_id" } + ); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RotateSecretTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RotateSecretTest.cs index 28f0d1a2a..8204935ab 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RotateSecretTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RotateSecretTest.cs @@ -359,7 +359,11 @@ public async Task MockServerTest() "resource_server_identifier": "resource_server_identifier", "async_approval_notification_channels": [ "guardian-push" - ] + ], + "external_metadata_type": "cimd", + "external_metadata_created_by": "admin", + "external_client_id": "external_client_id", + "jwks_uri": "jwks_uri" } """; diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/UpdateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/UpdateTest.cs index 71b87f08b..89adfe13c 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/UpdateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/UpdateTest.cs @@ -364,7 +364,11 @@ public async Task MockServerTest() "resource_server_identifier": "resource_server_identifier", "async_approval_notification_channels": [ "guardian-push" - ] + ], + "external_metadata_type": "cimd", + "external_metadata_created_by": "admin", + "external_client_id": "external_client_id", + "jwks_uri": "jwks_uri" } """; diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/CreateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/CreateTest.cs index 85d017c4a..275803437 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/CreateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/CreateTest.cs @@ -28,7 +28,7 @@ public async Task MockServerTest() } ], "synchronize_automatically": true, - "synchronize_groups": "synchronize_groups", + "synchronize_groups": "all", "created_at": "2024-01-15T09:30:00.000Z", "updated_at": "2024-01-15T09:30:00.000Z", "last_synchronization_at": "2024-01-15T09:30:00.000Z", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/GetTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/GetTest.cs index f8d438111..8894bb868 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/GetTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/GetTest.cs @@ -23,7 +23,7 @@ public async Task MockServerTest() } ], "synchronize_automatically": true, - "synchronize_groups": "synchronize_groups", + "synchronize_groups": "all", "created_at": "2024-01-15T09:30:00.000Z", "updated_at": "2024-01-15T09:30:00.000Z", "last_synchronization_at": "2024-01-15T09:30:00.000Z", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/ListTest.cs index a933ba1e5..dfb2a94c1 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/ListTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/ListTest.cs @@ -25,7 +25,7 @@ public async Task MockServerTest() } ], "synchronize_automatically": true, - "synchronize_groups": "synchronize_groups", + "synchronize_groups": "all", "created_at": "2024-01-15T09:30:00.000Z", "updated_at": "2024-01-15T09:30:00.000Z", "last_synchronization_at": "2024-01-15T09:30:00.000Z", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/UpdateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/UpdateTest.cs index c8e6c16bb..4b07cf17c 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/UpdateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Connections/DirectoryProvisioning/UpdateTest.cs @@ -28,7 +28,7 @@ public async Task MockServerTest() } ], "synchronize_automatically": true, - "synchronize_groups": "synchronize_groups", + "synchronize_groups": "all", "created_at": "2024-01-15T09:30:00.000Z", "updated_at": "2024-01-15T09:30:00.000Z", "last_synchronization_at": "2024-01-15T09:30:00.000Z", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/CustomDomains/GetDefaultTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/CustomDomains/GetDefaultTest.cs new file mode 100644 index 000000000..de65003be --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/CustomDomains/GetDefaultTest.cs @@ -0,0 +1,66 @@ +using Auth0.ManagementApi.Test.Unit.MockServer; +using Auth0.ManagementApi.Test.Utils; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.CustomDomains; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class GetDefaultTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_domain_id": "custom_domain_id", + "domain": "domain", + "primary": true, + "is_default": true, + "status": "pending_verification", + "type": "auth0_managed_certs", + "origin_domain_name": "origin_domain_name", + "verification": { + "methods": [ + { + "name": "cname", + "record": "record" + } + ], + "status": "verified", + "error_msg": "error_msg", + "last_verified_at": "last_verified_at" + }, + "custom_client_ip_header": "custom_client_ip_header", + "tls_policy": "tls_policy", + "domain_metadata": { + "key": "value" + }, + "certificate": { + "status": "provisioning", + "error_msg": "error_msg", + "certificate_authority": "letsencrypt", + "renews_before": "renews_before" + }, + "relying_party_identifier": "relying_party_identifier" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/custom-domains/default") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.CustomDomains.GetDefaultAsync(); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/CustomDomains/SetDefaultTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/CustomDomains/SetDefaultTest.cs new file mode 100644 index 000000000..ba9bc0b74 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/CustomDomains/SetDefaultTest.cs @@ -0,0 +1,77 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Test.Unit.MockServer; +using Auth0.ManagementApi.Test.Utils; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.CustomDomains; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class SetDefaultTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "domain": "domain" + } + """; + + const string mockResponse = """ + { + "custom_domain_id": "custom_domain_id", + "domain": "domain", + "primary": true, + "is_default": true, + "status": "pending_verification", + "type": "auth0_managed_certs", + "origin_domain_name": "origin_domain_name", + "verification": { + "methods": [ + { + "name": "cname", + "record": "record" + } + ], + "status": "verified", + "error_msg": "error_msg", + "last_verified_at": "last_verified_at" + }, + "custom_client_ip_header": "custom_client_ip_header", + "tls_policy": "tls_policy", + "domain_metadata": { + "key": "value" + }, + "certificate": { + "status": "provisioning", + "error_msg": "error_msg", + "certificate_authority": "letsencrypt", + "renews_before": "renews_before" + }, + "relying_party_identifier": "relying_party_identifier" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/custom-domains/default") + .WithHeader("Content-Type", "application/json") + .UsingPatch() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.CustomDomains.SetDefaultAsync( + new SetDefaultCustomDomainRequestContent { Domain = "domain" } + ); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/GetTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/GetTest.cs index c01ac213f..79e2535b8 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/GetTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/GetTest.cs @@ -52,6 +52,15 @@ public async Task MockServerTest() ], "user_agents": [ "user_agents" + ], + "hostnames": [ + "hostnames" + ], + "connecting_ipv4_cidrs": [ + "connecting_ipv4_cidrs" + ], + "connecting_ipv6_cidrs": [ + "connecting_ipv6_cidrs" ] }, "not_match": { @@ -81,6 +90,15 @@ public async Task MockServerTest() ], "user_agents": [ "user_agents" + ], + "hostnames": [ + "hostnames" + ], + "connecting_ipv4_cidrs": [ + "connecting_ipv4_cidrs" + ], + "connecting_ipv6_cidrs": [ + "connecting_ipv6_cidrs" ] }, "scope": "management" diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/SetTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/SetTest.cs index 1cdaea6d2..858ddda38 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/SetTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/SetTest.cs @@ -64,6 +64,15 @@ public async Task MockServerTest() ], "user_agents": [ "user_agents" + ], + "hostnames": [ + "hostnames" + ], + "connecting_ipv4_cidrs": [ + "connecting_ipv4_cidrs" + ], + "connecting_ipv6_cidrs": [ + "connecting_ipv6_cidrs" ] }, "not_match": { @@ -93,6 +102,15 @@ public async Task MockServerTest() ], "user_agents": [ "user_agents" + ], + "hostnames": [ + "hostnames" + ], + "connecting_ipv4_cidrs": [ + "connecting_ipv4_cidrs" + ], + "connecting_ipv6_cidrs": [ + "connecting_ipv6_cidrs" ] }, "scope": "management" diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/UpdateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/UpdateTest.cs index eead4ab5e..3b87fc6ae 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/UpdateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/NetworkAcls/UpdateTest.cs @@ -57,6 +57,15 @@ public async Task MockServerTest() ], "user_agents": [ "user_agents" + ], + "hostnames": [ + "hostnames" + ], + "connecting_ipv4_cidrs": [ + "connecting_ipv4_cidrs" + ], + "connecting_ipv6_cidrs": [ + "connecting_ipv6_cidrs" ] }, "not_match": { @@ -86,6 +95,15 @@ public async Task MockServerTest() ], "user_agents": [ "user_agents" + ], + "hostnames": [ + "hostnames" + ], + "connecting_ipv4_cidrs": [ + "connecting_ipv4_cidrs" + ], + "connecting_ipv6_cidrs": [ + "connecting_ipv6_cidrs" ] }, "scope": "management" diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/CreateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/CreateTest.cs new file mode 100644 index 000000000..b8dbb2178 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/CreateTest.cs @@ -0,0 +1,59 @@ +using Auth0.ManagementApi.Organizations; +using Auth0.ManagementApi.Test.Unit.MockServer; +using Auth0.ManagementApi.Test.Utils; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.Organizations.Connections; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "connection_id": "connection_id" + } + """; + + const string mockResponse = """ + { + "organization_connection_name": "organization_connection_name", + "assign_membership_on_login": true, + "show_as_button": true, + "is_signup_enabled": true, + "organization_access_level": "none", + "is_enabled": true, + "connection_id": "connection_id", + "connection": { + "name": "name", + "strategy": "strategy" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/organizations/id/connections") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Organizations.Connections.CreateAsync( + "id", + new CreateOrganizationAllConnectionRequestParameters { ConnectionId = "connection_id" } + ); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/DeleteTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/DeleteTest.cs new file mode 100644 index 000000000..9c224ad52 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/DeleteTest.cs @@ -0,0 +1,26 @@ +using Auth0.ManagementApi.Test.Unit.MockServer; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.Organizations.Connections; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public void MockServerTest() + { + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/organizations/id/connections/connection_id") + .UsingDelete() + ) + .RespondWith(WireMock.ResponseBuilders.Response.Create().WithStatusCode(200)); + + Assert.DoesNotThrowAsync(async () => + await Client.Organizations.Connections.DeleteAsync("id", "connection_id") + ); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/GetTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/GetTest.cs new file mode 100644 index 000000000..8de3b31cc --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/GetTest.cs @@ -0,0 +1,47 @@ +using Auth0.ManagementApi.Test.Unit.MockServer; +using Auth0.ManagementApi.Test.Utils; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.Organizations.Connections; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "organization_connection_name": "organization_connection_name", + "assign_membership_on_login": true, + "show_as_button": true, + "is_signup_enabled": true, + "organization_access_level": "none", + "is_enabled": true, + "connection_id": "connection_id", + "connection": { + "name": "name", + "strategy": "strategy" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/organizations/id/connections/connection_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Organizations.Connections.GetAsync("id", "connection_id"); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/ListTest.cs new file mode 100644 index 000000000..94c2c03ae --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/ListTest.cs @@ -0,0 +1,65 @@ +using Auth0.ManagementApi.Organizations; +using Auth0.ManagementApi.Test.Unit.MockServer; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.Organizations.Connections; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "start": 1.1, + "limit": 1.1, + "total": 1.1, + "connections": [ + { + "organization_connection_name": "organization_connection_name", + "assign_membership_on_login": true, + "show_as_button": true, + "is_signup_enabled": true, + "organization_access_level": "none", + "is_enabled": true, + "connection_id": "connection_id" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/organizations/id/connections") + .WithParam("page", "1") + .WithParam("per_page", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Organizations.Connections.ListAsync( + "id", + new ListOrganizationAllConnectionsRequestParameters + { + Page = 1, + PerPage = 1, + IncludeTotals = true, + IsEnabled = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/UpdateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/UpdateTest.cs new file mode 100644 index 000000000..5770d8f76 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Connections/UpdateTest.cs @@ -0,0 +1,58 @@ +using Auth0.ManagementApi.Organizations; +using Auth0.ManagementApi.Test.Unit.MockServer; +using Auth0.ManagementApi.Test.Utils; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.Organizations.Connections; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + {} + """; + + const string mockResponse = """ + { + "organization_connection_name": "organization_connection_name", + "assign_membership_on_login": true, + "show_as_button": true, + "is_signup_enabled": true, + "organization_access_level": "none", + "is_enabled": true, + "connection_id": "connection_id", + "connection": { + "name": "name", + "strategy": "strategy" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/organizations/id/connections/connection_id") + .WithHeader("Content-Type", "application/json") + .UsingPatch() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Organizations.Connections.UpdateAsync( + "id", + "connection_id", + new UpdateOrganizationConnectionRequestParameters() + ); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/RefreshTokens/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/RefreshTokens/ListTest.cs new file mode 100644 index 000000000..55357ab71 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/RefreshTokens/ListTest.cs @@ -0,0 +1,75 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Test.Unit.MockServer; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.RefreshTokens; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "refresh_tokens": [ + { + "id": "id", + "user_id": "user_id", + "created_at": "2024-01-15T09:30:00.000Z", + "idle_expires_at": "2024-01-15T09:30:00.000Z", + "expires_at": "2024-01-15T09:30:00.000Z", + "client_id": "client_id", + "session_id": "session_id", + "rotating": true, + "resource_servers": [ + {} + ], + "refresh_token_metadata": { + "key": "value" + }, + "last_exchanged_at": "2024-01-15T09:30:00.000Z" + } + ], + "next": "next" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/refresh-tokens") + .WithParam("user_id", "user_id") + .WithParam("client_id", "client_id") + .WithParam("from", "from") + .WithParam("take", "1") + .WithParam("fields", "fields") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.RefreshTokens.ListAsync( + new GetRefreshTokensRequestParameters + { + UserId = "user_id", + ClientId = "client_id", + From = "from", + Take = 1, + Fields = "fields", + IncludeFields = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +}