diff --git a/.fern/metadata.json b/.fern/metadata.json index 11def20c..064ebca3 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -10,10 +10,10 @@ "base-exception-class-name": "CloudPDFException", "base-api-exception-class-name": "CloudPDFApiException" }, - "originGitCommit": "622018abaf6e4578d1f4d8377982c48b92c9ced3", + "originGitCommit": "3283147ded32fc15c426768f75557a4d95943d84", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "3.0.0-next.20", + "requestedVersion": "3.0.0-next.21", "ciProvider": "github", - "sdkVersion": "3.0.0-next.20" + "sdkVersion": "3.0.0-next.21" } \ No newline at end of file diff --git a/cloudpdf-generation.json b/cloudpdf-generation.json index ae205dc0..56d7f3c7 100644 --- a/cloudpdf-generation.json +++ b/cloudpdf-generation.json @@ -1,12 +1,12 @@ { "language": "csharp", - "canonicalVersion": "3.0.0-next.20", - "sdkVersion": "3.0.0-next.20", + "canonicalVersion": "3.0.0-next.21", + "sdkVersion": "3.0.0-next.21", "source": { "repository": "embedpdf/embed-pdf-viewer", "openapi": "cloudpdf/contract/openapi.json", - "openapiSha256": "47d739acb956ce8ba0c3990117e505be2e9406038d9e0cd1729608921a40b2d9", - "gitCommit": "622018abaf6e4578d1f4d8377982c48b92c9ced3", + "openapiSha256": "f85648401f5c683a32e2b50acc3d753df9f4ce06df8492e5d2b599beceb0e788", + "gitCommit": "3283147ded32fc15c426768f75557a4d95943d84", "gitCommitIsDirty": false }, "fern": { diff --git a/reference.md b/reference.md index 16a10b76..f66e028a 100644 --- a/reference.md +++ b/reference.md @@ -881,6 +881,66 @@ await client.Tenants.DeleteAsync(new DeleteTenantsRequest { TenantId = "tenantId + + + + +
client.Tenants.UpdateAsync(TenantsUpdateRequest { ... }) -> WithRawResponseTask<TenantsUpdate200Response> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +A feature names an installed module; any other id is a 400. A module route answers a tenant without its feature 403 FeatureNotEnabled, and one whose feature is stopped 402 FeatureStopped (details.feature, details.stopped). Other replicas apply a change within 30 seconds. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Tenants.UpdateAsync( + new TenantsUpdateRequest + { + TenantId = "tenantId", + Features = new List() { new TenantFeature { Id = "id" } }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `TenantsUpdateRequest` + +
+
+
+
+ +
diff --git a/src/CloudPDF.Test/Unit/MockServer/Tenants/CreateTest.cs b/src/CloudPDF.Test/Unit/MockServer/Tenants/CreateTest.cs index a9ad6b2f..c0b6db06 100644 --- a/src/CloudPDF.Test/Unit/MockServer/Tenants/CreateTest.cs +++ b/src/CloudPDF.Test/Unit/MockServer/Tenants/CreateTest.cs @@ -25,6 +25,16 @@ public async Task MockServerTest_1() "name": "name", "autoProvisioned": true, "status": "active", + "features": [ + { + "id": "id", + "stopped": "cap" + }, + { + "id": "id", + "stopped": "cap" + } + ], "createdAt": 1.1 }, "created": true @@ -69,6 +79,11 @@ public async Task MockServerTest_2() "name": "name", "autoProvisioned": true, "status": "active", + "features": [ + { + "id": "id" + } + ], "createdAt": 1.1 }, "created": true diff --git a/src/CloudPDF.Test/Unit/MockServer/Tenants/GetTest.cs b/src/CloudPDF.Test/Unit/MockServer/Tenants/GetTest.cs index a3a19db4..15116bc6 100644 --- a/src/CloudPDF.Test/Unit/MockServer/Tenants/GetTest.cs +++ b/src/CloudPDF.Test/Unit/MockServer/Tenants/GetTest.cs @@ -19,6 +19,16 @@ public async Task MockServerTest_1() "name": "name", "autoProvisioned": true, "status": "active", + "features": [ + { + "id": "id", + "stopped": "cap" + }, + { + "id": "id", + "stopped": "cap" + } + ], "createdAt": 1.1 } } @@ -54,6 +64,11 @@ public async Task MockServerTest_2() "name": "name", "autoProvisioned": true, "status": "active", + "features": [ + { + "id": "id" + } + ], "createdAt": 1.1 } } diff --git a/src/CloudPDF.Test/Unit/MockServer/Tenants/ListTest.cs b/src/CloudPDF.Test/Unit/MockServer/Tenants/ListTest.cs index 1be4912b..8dd372ab 100644 --- a/src/CloudPDF.Test/Unit/MockServer/Tenants/ListTest.cs +++ b/src/CloudPDF.Test/Unit/MockServer/Tenants/ListTest.cs @@ -20,6 +20,16 @@ public async Task MockServerTest_1() "name": "name", "autoProvisioned": true, "status": "active", + "features": [ + { + "id": "id", + "stopped": "cap" + }, + { + "id": "id", + "stopped": "cap" + } + ], "createdAt": 1.1 }, { @@ -27,6 +37,16 @@ public async Task MockServerTest_1() "name": "name", "autoProvisioned": true, "status": "active", + "features": [ + { + "id": "id", + "stopped": "cap" + }, + { + "id": "id", + "stopped": "cap" + } + ], "createdAt": 1.1 } ], @@ -58,6 +78,11 @@ public async Task MockServerTest_2() "name": "name", "autoProvisioned": true, "status": "active", + "features": [ + { + "id": "id" + } + ], "createdAt": 1.1 } ], diff --git a/src/CloudPDF.Test/Unit/MockServer/Tenants/UpdateTest.cs b/src/CloudPDF.Test/Unit/MockServer/Tenants/UpdateTest.cs new file mode 100644 index 00000000..f018a53b --- /dev/null +++ b/src/CloudPDF.Test/Unit/MockServer/Tenants/UpdateTest.cs @@ -0,0 +1,135 @@ +using CloudPDF; +using CloudPDF.Test.Unit.MockServer; +using CloudPDF.Test.Utils; +using NUnit.Framework; + +namespace CloudPDF.Test.Unit.MockServer.Tenants; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest_1() + { + const string requestJson = """ + { + "features": [ + { + "id": "id" + }, + { + "id": "id" + } + ] + } + """; + + const string mockResponse = """ + { + "tenant": { + "id": "id", + "name": "name", + "autoProvisioned": true, + "status": "active", + "features": [ + { + "id": "id", + "stopped": "cap" + }, + { + "id": "id", + "stopped": "cap" + } + ], + "createdAt": 1.1 + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v1/tenants/tenantId") + .WithHeader("Content-Type", "application/json") + .UsingPatch() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Tenants.UpdateAsync( + new TenantsUpdateRequest + { + TenantId = "tenantId", + Features = new List() + { + new TenantFeature { Id = "id", Stopped = null }, + new TenantFeature { Id = "id", Stopped = null }, + }, + } + ); + JsonAssert.AreEqual(response, mockResponse); + } + + [NUnit.Framework.Test] + public async Task MockServerTest_2() + { + const string requestJson = """ + { + "features": [ + { + "id": "id" + } + ] + } + """; + + const string mockResponse = """ + { + "tenant": { + "id": "id", + "name": "name", + "autoProvisioned": true, + "status": "active", + "features": [ + { + "id": "id" + } + ], + "createdAt": 1.1 + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v1/tenants/tenantId") + .WithHeader("Content-Type", "application/json") + .UsingPatch() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Tenants.UpdateAsync( + new TenantsUpdateRequest + { + TenantId = "tenantId", + Features = new List() { new TenantFeature { Id = "id" } }, + } + ); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/src/CloudPDF/CloudPDF.csproj b/src/CloudPDF/CloudPDF.csproj index 89e839ef..8340d1b8 100644 --- a/src/CloudPDF/CloudPDF.csproj +++ b/src/CloudPDF/CloudPDF.csproj @@ -11,7 +11,7 @@ enable 12 enable - 3.0.0-next.20 + 3.0.0-next.21 3.0.0.0 3.0.0.0 README.md diff --git a/src/CloudPDF/Core/Public/Version.cs b/src/CloudPDF/Core/Public/Version.cs index 62cb9f6d..2287fd74 100644 --- a/src/CloudPDF/Core/Public/Version.cs +++ b/src/CloudPDF/Core/Public/Version.cs @@ -3,5 +3,5 @@ namespace CloudPDF; [Serializable] internal class Version { - public const string Current = "3.0.0-next.20"; + public const string Current = "3.0.0-next.21"; } diff --git a/src/CloudPDF/Tenants/ITenantsClient.cs b/src/CloudPDF/Tenants/ITenantsClient.cs index e6a1cd7d..e69d76fc 100644 --- a/src/CloudPDF/Tenants/ITenantsClient.cs +++ b/src/CloudPDF/Tenants/ITenantsClient.cs @@ -29,6 +29,15 @@ WithRawResponseTask DeleteAsync( CancellationToken cancellationToken = default ); + /// + /// A feature names an installed module; any other id is a 400. A module route answers a tenant without its feature 403 FeatureNotEnabled, and one whose feature is stopped 402 FeatureStopped (details.feature, details.stopped). Other replicas apply a change within 30 seconds. + /// + WithRawResponseTask UpdateAsync( + TenantsUpdateRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + WithRawResponseTask ResumeAsync( ResumeTenantsRequest request, RequestOptions? options = null, diff --git a/src/CloudPDF/Tenants/Requests/TenantsUpdateRequest.cs b/src/CloudPDF/Tenants/Requests/TenantsUpdateRequest.cs new file mode 100644 index 00000000..a2c4c3ad --- /dev/null +++ b/src/CloudPDF/Tenants/Requests/TenantsUpdateRequest.cs @@ -0,0 +1,20 @@ +using CloudPDF.Core; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record TenantsUpdateRequest +{ + [JsonIgnore] + public required string TenantId { get; set; } + + [JsonPropertyName("features")] + public IEnumerable Features { get; set; } = new List(); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Tenants/TenantsClient.cs b/src/CloudPDF/Tenants/TenantsClient.cs index 556d7153..e115ac21 100644 --- a/src/CloudPDF/Tenants/TenantsClient.cs +++ b/src/CloudPDF/Tenants/TenantsClient.cs @@ -408,6 +408,126 @@ private async Task DeleteAsyncCore( } } + private async Task> UpdateAsyncCore( + TenantsUpdateRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new CloudPDF.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new CloudPDF.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( + "v1/tenants/{0}", + ValueConvert.ToPathParameterString(request.TenantId) + ), + Body = request, + QueryString = _queryString, + 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 CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new CloudPDFApiException( + "Failed to deserialize response", + response.StatusCode, + responseBody, + e, + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new CloudPDFApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + private async Task ResumeAsyncCore( ResumeTenantsRequest request, RequestOptions? options = null, @@ -746,6 +866,29 @@ public WithRawResponseTask DeleteAsync( return new WithRawResponseTask(DeleteAsyncCore(request, options, cancellationToken)); } + /// + /// A feature names an installed module; any other id is a 400. A module route answers a tenant without its feature 403 FeatureNotEnabled, and one whose feature is stopped 402 FeatureStopped (details.feature, details.stopped). Other replicas apply a change within 30 seconds. + /// + /// + /// await client.Tenants.UpdateAsync( + /// new TenantsUpdateRequest + /// { + /// TenantId = "tenantId", + /// Features = new List<TenantFeature>() { new TenantFeature { Id = "id" } }, + /// } + /// ); + /// + public WithRawResponseTask UpdateAsync( + TenantsUpdateRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + UpdateAsyncCore(request, options, cancellationToken) + ); + } + /// /// await client.Tenants.ResumeAsync(new ResumeTenantsRequest { TenantId = "tenantId" }); /// diff --git a/src/CloudPDF/Types/TenantFeature.cs b/src/CloudPDF/Types/TenantFeature.cs new file mode 100644 index 00000000..f0f46dcb --- /dev/null +++ b/src/CloudPDF/Types/TenantFeature.cs @@ -0,0 +1,31 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record TenantFeature : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("stopped")] + public TenantFeatureStopped? Stopped { 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/CloudPDF/Types/TenantFeatureStopped.cs b/src/CloudPDF/Types/TenantFeatureStopped.cs new file mode 100644 index 00000000..af0a0dcb --- /dev/null +++ b/src/CloudPDF/Types/TenantFeatureStopped.cs @@ -0,0 +1,111 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter(typeof(TenantFeatureStopped.TenantFeatureStoppedSerializer))] +[Serializable] +public readonly record struct TenantFeatureStopped : IStringEnum +{ + public static readonly TenantFeatureStopped Cap = new(Values.Cap); + + public TenantFeatureStopped(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static TenantFeatureStopped FromCustom(string value) + { + return new TenantFeatureStopped(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 ==(TenantFeatureStopped value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(TenantFeatureStopped value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(TenantFeatureStopped value) => value.Value; + + public static explicit operator TenantFeatureStopped(string value) => new(value); + + internal class TenantFeatureStoppedSerializer : JsonConverter + { + public override TenantFeatureStopped 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 TenantFeatureStopped(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + TenantFeatureStopped value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override TenantFeatureStopped 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 TenantFeatureStopped(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + TenantFeatureStopped value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Cap = "cap"; + } +} diff --git a/src/CloudPDF/Types/TenantsCreate200ResponseTenant.cs b/src/CloudPDF/Types/TenantsCreate200ResponseTenant.cs index a56f6756..30bd1785 100644 --- a/src/CloudPDF/Types/TenantsCreate200ResponseTenant.cs +++ b/src/CloudPDF/Types/TenantsCreate200ResponseTenant.cs @@ -23,6 +23,9 @@ public record TenantsCreate200ResponseTenant : IJsonOnDeserialized [JsonPropertyName("status")] public TenantsCreate200ResponseTenantStatus? Status { get; set; } + [JsonPropertyName("features")] + public IEnumerable? Features { get; set; } + [JsonPropertyName("createdAt")] public required double CreatedAt { get; set; } diff --git a/src/CloudPDF/Types/TenantsGet200ResponseTenant.cs b/src/CloudPDF/Types/TenantsGet200ResponseTenant.cs index 069a913a..e3871f5b 100644 --- a/src/CloudPDF/Types/TenantsGet200ResponseTenant.cs +++ b/src/CloudPDF/Types/TenantsGet200ResponseTenant.cs @@ -23,6 +23,9 @@ public record TenantsGet200ResponseTenant : IJsonOnDeserialized [JsonPropertyName("status")] public TenantsGet200ResponseTenantStatus? Status { get; set; } + [JsonPropertyName("features")] + public IEnumerable? Features { get; set; } + [JsonPropertyName("createdAt")] public required double CreatedAt { get; set; } diff --git a/src/CloudPDF/Types/TenantsList200ResponseTenantsItem.cs b/src/CloudPDF/Types/TenantsList200ResponseTenantsItem.cs index b28757fa..6fe9e33a 100644 --- a/src/CloudPDF/Types/TenantsList200ResponseTenantsItem.cs +++ b/src/CloudPDF/Types/TenantsList200ResponseTenantsItem.cs @@ -23,6 +23,9 @@ public record TenantsList200ResponseTenantsItem : IJsonOnDeserialized [JsonPropertyName("status")] public TenantsList200ResponseTenantsItemStatus? Status { get; set; } + [JsonPropertyName("features")] + public IEnumerable? Features { get; set; } + [JsonPropertyName("createdAt")] public required double CreatedAt { get; set; } diff --git a/src/CloudPDF/Types/TenantsUpdate200Response.cs b/src/CloudPDF/Types/TenantsUpdate200Response.cs new file mode 100644 index 00000000..50d897d5 --- /dev/null +++ b/src/CloudPDF/Types/TenantsUpdate200Response.cs @@ -0,0 +1,28 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record TenantsUpdate200Response : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("tenant")] + public required TenantsUpdate200ResponseTenant Tenant { 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/CloudPDF/Types/TenantsUpdate200ResponseTenant.cs b/src/CloudPDF/Types/TenantsUpdate200ResponseTenant.cs new file mode 100644 index 00000000..d3502c0b --- /dev/null +++ b/src/CloudPDF/Types/TenantsUpdate200ResponseTenant.cs @@ -0,0 +1,43 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record TenantsUpdate200ResponseTenant : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("autoProvisioned")] + public required bool AutoProvisioned { get; set; } + + [JsonPropertyName("status")] + public TenantsUpdate200ResponseTenantStatus? Status { get; set; } + + [JsonPropertyName("features")] + public IEnumerable? Features { get; set; } + + [JsonPropertyName("createdAt")] + public required double CreatedAt { 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/CloudPDF/Types/TenantsUpdate200ResponseTenantStatus.cs b/src/CloudPDF/Types/TenantsUpdate200ResponseTenantStatus.cs new file mode 100644 index 00000000..8bc43092 --- /dev/null +++ b/src/CloudPDF/Types/TenantsUpdate200ResponseTenantStatus.cs @@ -0,0 +1,120 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter( + typeof(TenantsUpdate200ResponseTenantStatus.TenantsUpdate200ResponseTenantStatusSerializer) +)] +[Serializable] +public readonly record struct TenantsUpdate200ResponseTenantStatus : IStringEnum +{ + public static readonly TenantsUpdate200ResponseTenantStatus Active = new(Values.Active); + + public static readonly TenantsUpdate200ResponseTenantStatus Suspended = new(Values.Suspended); + + public TenantsUpdate200ResponseTenantStatus(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static TenantsUpdate200ResponseTenantStatus FromCustom(string value) + { + return new TenantsUpdate200ResponseTenantStatus(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 ==(TenantsUpdate200ResponseTenantStatus value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(TenantsUpdate200ResponseTenantStatus value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(TenantsUpdate200ResponseTenantStatus value) => + value.Value; + + public static explicit operator TenantsUpdate200ResponseTenantStatus(string value) => + new(value); + + internal class TenantsUpdate200ResponseTenantStatusSerializer + : JsonConverter + { + public override TenantsUpdate200ResponseTenantStatus 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 TenantsUpdate200ResponseTenantStatus(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + TenantsUpdate200ResponseTenantStatus value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override TenantsUpdate200ResponseTenantStatus 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 TenantsUpdate200ResponseTenantStatus(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + TenantsUpdate200ResponseTenantStatus value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Active = "active"; + + public const string Suspended = "suspended"; + } +}