From 46fe56f604e5599cb86e25ba84db9ae6e5d1db5b Mon Sep 17 00:00:00 2001 From: Kyle Dodson Date: Wed, 11 Sep 2024 16:50:16 -0700 Subject: [PATCH] liblab SDK update v0.9.0-alpha.2 (#4) --- .manifest.json | 20 ++++++++++--------- README.md | 4 ++-- Salad.Cloud.IMDS.SDK/Http/ApiException.cs | 16 +++++++++++++++ .../HttpResponseMessageExtensions.ejs';}.cs | 15 ++++++++++++++ .../Salad.Cloud.IMDS.SDK.csproj | 8 ++++---- .../Services/MetadataService.cs | 9 ++++++--- documentation/models/ContainerStatus.md | 8 ++++---- documentation/models/ContainerToken.md | 6 +++--- documentation/models/ReallocateContainer.md | 6 +++--- documentation/services/MetadataService.md | 6 +++--- 10 files changed, 67 insertions(+), 31 deletions(-) create mode 100644 Salad.Cloud.IMDS.SDK/Http/ApiException.cs create mode 100644 Salad.Cloud.IMDS.SDK/Http/HttpResponseMessageExtensions.ejs';}.cs diff --git a/.manifest.json b/.manifest.json index c5da944..25aa945 100644 --- a/.manifest.json +++ b/.manifest.json @@ -1,10 +1,10 @@ { - "liblabVersion": "2.1.31", - "date": "2024-09-06T14:42:20.403Z", + "liblabVersion": "2.3.1", + "date": "2024-09-11T23:34:37.035Z", "config": { "apiId": 1126, "sdkName": "salad-cloud-imds-sdk", - "sdkVersion": "0.9.0-alpha.1", + "sdkVersion": "0.9.0-alpha.2", "liblabVersion": "2", "deliveryMethods": ["zip"], "languages": ["csharp"], @@ -25,7 +25,7 @@ "homepage": "https://github.com/saladtechnologies/salad-cloud-imds-sdk-dotnet", "ignoreFiles": [".gitignore", "./LICENSE"], "liblabVersion": "2", - "sdkVersion": "0.9.0-alpha.1", + "sdkVersion": "0.9.0-alpha.2", "targetBranch": "main" }, "go": { @@ -33,7 +33,7 @@ "githubRepoName": "salad-cloud-imds-sdk-go", "ignoreFiles": [".gitignore", "./LICENSE"], "liblabVersion": "2", - "sdkVersion": "0.9.0-alpha.1", + "sdkVersion": "0.9.0-alpha.2", "targetBranch": "main" }, "java": { @@ -57,7 +57,7 @@ "homepage": "https://github.com/saladtechnologies/salad-cloud-imds-sdk-java", "ignoreFiles": [".gitignore", "./LICENSE"], "liblabVersion": "2", - "sdkVersion": "0.9.0-alpha.1", + "sdkVersion": "0.9.0-alpha.2", "targetBranch": "main" }, "python": { @@ -100,7 +100,7 @@ "githubRepoName": "salad-cloud-imds-sdk-python", "ignoreFiles": [".gitignore", "./LICENSE"], "liblabVersion": "2", - "sdkVersion": "0.9.0-alpha.1", + "sdkVersion": "0.9.0-alpha.2", "targetBranch": "main" }, "typescript": { @@ -123,7 +123,7 @@ "homepage": "https://github.com/saladtechnologies/salad-cloud-imds-sdk-javascript", "ignoreFiles": [".gitignore", "./LICENSE"], "liblabVersion": "2", - "sdkVersion": "0.9.0-alpha.1", + "sdkVersion": "0.9.0-alpha.2", "targetBranch": "main" } }, @@ -155,7 +155,7 @@ }, "multiTenant": true, "hooksLocation": { - "bucketKey": "7034/hooks.zip", + "bucketKey": "7096/hooks.zip", "bucketName": "prod-liblab-api-stack-hooks" }, "includeWatermark": false, @@ -223,6 +223,8 @@ "documentation/models/ContainerStatus.md", "documentation/models/ContainerToken.md", ".devcontainer/devcontainer.json", + "Salad.Cloud.IMDS.SDK/Http/ApiException.cs", + "Salad.Cloud.IMDS.SDK/Http/HttpResponseMessageExtensions.ejs';}.cs", "Salad.Cloud.IMDS.SDK/Models/ReallocateContainer.cs", "Salad.Cloud.IMDS.SDK/Models/ContainerStatus.cs", "Salad.Cloud.IMDS.SDK/Models/ContainerToken.cs", diff --git a/README.md b/README.md index b93b7c9..2ba1da3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# SaladCloudImdsSdk C# SDK 0.9.0-alpha.1 +# SaladCloudImdsSdk C# SDK 0.9.0-alpha.2 Welcome to the SaladCloudImdsSdk SDK documentation. This guide will help you get started with integrating and using the SaladCloudImdsSdk SDK in your project. ## Versions - API version: `0.9.0-alpha.1` -- SDK version: `0.9.0-alpha.1` +- SDK version: `0.9.0-alpha.2` ## About the API diff --git a/Salad.Cloud.IMDS.SDK/Http/ApiException.cs b/Salad.Cloud.IMDS.SDK/Http/ApiException.cs new file mode 100644 index 0000000..65f3933 --- /dev/null +++ b/Salad.Cloud.IMDS.SDK/Http/ApiException.cs @@ -0,0 +1,16 @@ +namespace Salad.Cloud.IMDS.SDK.Http.Exceptions; + +public class ApiException : HttpRequestException +{ + public HttpResponseMessage Response { get; } + + public ApiException(HttpResponseMessage responseMessage) + : base( + $"Response status code does not indicate success: {(int)responseMessage.StatusCode} ({responseMessage.StatusCode}).", + null, + responseMessage.StatusCode + ) + { + Response = responseMessage; + } +} diff --git a/Salad.Cloud.IMDS.SDK/Http/HttpResponseMessageExtensions.ejs';}.cs b/Salad.Cloud.IMDS.SDK/Http/HttpResponseMessageExtensions.ejs';}.cs new file mode 100644 index 0000000..b656028 --- /dev/null +++ b/Salad.Cloud.IMDS.SDK/Http/HttpResponseMessageExtensions.ejs';}.cs @@ -0,0 +1,15 @@ +using Salad.Cloud.IMDS.SDK.Http.Exceptions; + +namespace Salad.Cloud.IMDS.SDK.Http.Extensions; + +public static class HttpResponseMessageExtensions +{ + public static HttpResponseMessage EnsureSuccessfulResponse(this HttpResponseMessage response) + { + if (!response.IsSuccessStatusCode) + { + throw new ApiException(response); + } + return response; + } +} diff --git a/Salad.Cloud.IMDS.SDK/Salad.Cloud.IMDS.SDK.csproj b/Salad.Cloud.IMDS.SDK/Salad.Cloud.IMDS.SDK.csproj index b1b180b..6fc208b 100644 --- a/Salad.Cloud.IMDS.SDK/Salad.Cloud.IMDS.SDK.csproj +++ b/Salad.Cloud.IMDS.SDK/Salad.Cloud.IMDS.SDK.csproj @@ -5,7 +5,7 @@ enable enable Salad.Cloud.IMDS.SDK - 0.9.0-alpha.1 + 0.9.0-alpha.2 Salad.Cloud.IMDS.SDK salad, seniorquico https://github.com/saladtechnologies/salad-cloud-imds-sdk-dotnet @@ -18,9 +18,9 @@ - - - + + + diff --git a/Salad.Cloud.IMDS.SDK/Services/MetadataService.cs b/Salad.Cloud.IMDS.SDK/Services/MetadataService.cs index 2074b6f..1ef37ef 100644 --- a/Salad.Cloud.IMDS.SDK/Services/MetadataService.cs +++ b/Salad.Cloud.IMDS.SDK/Services/MetadataService.cs @@ -1,5 +1,7 @@ using System.Net.Http.Json; using Salad.Cloud.IMDS.SDK.Http; +using Salad.Cloud.IMDS.SDK.Http.Exceptions; +using Salad.Cloud.IMDS.SDK.Http.Extensions; using Salad.Cloud.IMDS.SDK.Http.Serialization; using Salad.Cloud.IMDS.SDK.Models; @@ -25,7 +27,8 @@ public async Task ReallocateContainerAsync( var response = await _httpClient .SendAsync(request, cancellationToken) .ConfigureAwait(false); - response.EnsureSuccessStatusCode(); + + response.EnsureSuccessfulResponse(); } /// Gets the health statuses of the running container @@ -38,9 +41,9 @@ public async Task GetContainerStatusAsync( var response = await _httpClient .SendAsync(request, cancellationToken) .ConfigureAwait(false); - response.EnsureSuccessStatusCode(); return await response + .EnsureSuccessfulResponse() .Content.ReadFromJsonAsync( _jsonSerializerOptions, cancellationToken @@ -58,9 +61,9 @@ public async Task GetContainerTokenAsync( var response = await _httpClient .SendAsync(request, cancellationToken) .ConfigureAwait(false); - response.EnsureSuccessStatusCode(); return await response + .EnsureSuccessfulResponse() .Content.ReadFromJsonAsync( _jsonSerializerOptions, cancellationToken diff --git a/documentation/models/ContainerStatus.md b/documentation/models/ContainerStatus.md index bf9ffa7..09fba87 100644 --- a/documentation/models/ContainerStatus.md +++ b/documentation/models/ContainerStatus.md @@ -4,7 +4,7 @@ Represents the health statuses of the running container. **Properties** -| Name | Type | Required | Description | -| :------ | :--- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Ready | bool | ✅ | `true` if the running container is ready. If a readiness probe is defined, this returns the latest result of the probe. If a readiness probe is not defined but a startup probe is defined, this returns the same value as the `started` property. If neither a readiness probe nor a startup probe are defined, returns `true`. | -| Started | bool | ✅ | `true` if the running container is started. If a startup probe is defined, this returns the latest result of the probe. If a startup probe is not defined, returns `true`. | +| Name | Type | Required | Description | +| :------ | :----- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Ready | `bool` | ✅ | `true` if the running container is ready. If a readiness probe is defined, this returns the latest result of the probe. If a readiness probe is not defined but a startup probe is defined, this returns the same value as the `started` property. If neither a readiness probe nor a startup probe are defined, returns `true`. | +| Started | `bool` | ✅ | `true` if the running container is started. If a startup probe is defined, this returns the latest result of the probe. If a startup probe is not defined, returns `true`. | diff --git a/documentation/models/ContainerToken.md b/documentation/models/ContainerToken.md index 7c78a3f..7eee9e7 100644 --- a/documentation/models/ContainerToken.md +++ b/documentation/models/ContainerToken.md @@ -4,6 +4,6 @@ Represents the identity token of the running container. **Properties** -| Name | Type | Required | Description | -| :--- | :----- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Jwt | string | ✅ | The JSON Web Token (JWT) that may be used to identify the running container. The JWT may be verified using the JSON Web Key Set (JWKS) available at https://matrix-rest-api.salad.com/.well-known/stash-jwks.json. | +| Name | Type | Required | Description | +| :--- | :------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Jwt | `string` | ✅ | The JSON Web Token (JWT) that may be used to identify the running container. The JWT may be verified using the JSON Web Key Set (JWKS) available at https://matrix-rest-api.salad.com/.well-known/stash-jwks.json. | diff --git a/documentation/models/ReallocateContainer.md b/documentation/models/ReallocateContainer.md index b55427c..eb3a3cf 100644 --- a/documentation/models/ReallocateContainer.md +++ b/documentation/models/ReallocateContainer.md @@ -4,6 +4,6 @@ Represents a request to reallocate a container. **Properties** -| Name | Type | Required | Description | -| :----- | :----- | :------- | :---------------------------------------------------------------------------------------------------------------------------- | -| Reason | string | ✅ | The reason for reallocating the container. This value is reported to SaladCloud support for quality assurance of Salad Nodes. | +| Name | Type | Required | Description | +| :----- | :------- | :------- | :---------------------------------------------------------------------------------------------------------------------------- | +| Reason | `string` | ✅ | The reason for reallocating the container. This value is reported to SaladCloud support for quality assurance of Salad Nodes. | diff --git a/documentation/services/MetadataService.md b/documentation/services/MetadataService.md index 275c6dc..b8dcf96 100644 --- a/documentation/services/MetadataService.md +++ b/documentation/services/MetadataService.md @@ -17,9 +17,9 @@ Reallocates the running container to another Salad Node **Parameters** -| Name | Type | Required | Description | -| :---- | :------------------ | :------- | :---------------- | -| input | ReallocateContainer | ✅ | The request body. | +| Name | Type | Required | Description | +| :---- | :-------------------- | :------- | :---------------- | +| input | `ReallocateContainer` | ✅ | The request body. | **Example Usage Code Snippet**