Skip to content

Commit

Permalink
liblab SDK update for version v0.9.0-alpha.2
Browse files Browse the repository at this point in the history
  • Loading branch information
seniorquico committed Sep 11, 2024
1 parent d5a911e commit c78285e
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 85 deletions.
19 changes: 9 additions & 10 deletions .manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"liblabVersion": "2.1.31",
"date": "2024-09-06T14:42:21.566Z",
"liblabVersion": "2.3.1",
"date": "2024-09-11T23:34:37.047Z",
"config": {
"language": "go",
"apiId": 1126,
"sdkName": "salad-cloud-imds-sdk",
"sdkVersion": "0.9.0-alpha.1",
"sdkVersion": "0.9.0-alpha.2",
"liblabVersion": "2",
"deliveryMethods": ["zip"],
"languages": ["go"],
Expand All @@ -26,15 +26,15 @@
"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": {
"goModuleName": "github.com/saladtechnologies/salad-cloud-imds-sdk-go",
"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": {
Expand All @@ -58,7 +58,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": {
Expand Down Expand Up @@ -101,7 +101,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": {
Expand All @@ -124,7 +124,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"
}
},
Expand Down Expand Up @@ -156,7 +156,7 @@
},
"multiTenant": true,
"hooksLocation": {
"bucketKey": "7034/hooks.zip",
"bucketKey": "7096/hooks.zip",
"bucketName": "prod-liblab-api-stack-hooks"
},
"includeWatermark": false,
Expand Down Expand Up @@ -208,7 +208,6 @@
"internal/clients/rest/handlers/hook_handler.go",
"internal/clients/rest/hooks/hook.go",
"internal/clients/rest/hooks/custom_hook.go",
"internal/clients/rest/handlers/default_headers_handler.go",
"internal/clients/rest/handlers/retry_handler.go",
"internal/clients/rest/handlers/request_validation_handler.go",
"internal/validation/validation.go",
Expand Down
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SaladCloudImdsSdk Go SDK 0.9.0-alpha.1
# SaladCloudImdsSdk Go 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

Expand All @@ -17,6 +17,7 @@ The SaladCloud Instance Metadata Service (IMDS). Please refer to the [SaladCloud
- [Supported Language Versions](#supported-language-versions)
- [Installation](#installation)
- [Services](#services)
- [Response Wrappers](#response-wrappers)
- [Models](#models)
- [License](#license)

Expand All @@ -39,6 +40,45 @@ The SDK provides various services to interact with the API.

</details>

### Response Wrappers

All services use response wrappers to provide a consistent interface to return the responses from the API.

The response wrapper itself is a generic struct that contains the response data and metadata.

<details>
<summary>Below are the response wrappers used in the SDK:</summary>

#### `SaladCloudImdsSdkResponse[T]`

This response wrapper is used to return the response data from the API. It contains the following fields:

| Name | Type | Description |
| :------- | :---------------------------------- | :------------------------------------------ |
| Data | `T` | The body of the API response |
| Metadata | `SaladCloudImdsSdkResponseMetadata` | Status code and headers returned by the API |

#### `SaladCloudImdsSdkError`

This response wrapper is used to return an error. It contains the following fields:

| Name | Type | Description |
| :------- | :---------------------------------- | :------------------------------------------ |
| Err | `error` | The error that occurred |
| Body | `T` | The body of the API response |
| Metadata | `SaladCloudImdsSdkResponseMetadata` | Status code and headers returned by the API |

#### `SaladCloudImdsSdkResponseMetadata`

This struct is shared by both response wrappers and contains the following fields:

| Name | Type | Description |
| :--------- | :------------------ | :----------------------------------------------- |
| Headers | `map[string]string` | A map containing the headers returned by the API |
| StatusCode | `int` | The status code returned by the API |

</details>

## Models

The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.
Expand Down
8 changes: 4 additions & 4 deletions documentation/models/container_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`. |
6 changes: 3 additions & 3 deletions documentation/models/container_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
6 changes: 3 additions & 3 deletions documentation/models/reallocate_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
20 changes: 10 additions & 10 deletions documentation/services/metadata_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Reallocates the running container to another Salad Node

**Parameters**

| Name | Type | Required | Description |
| :------------------ | :------------------ | :------- | :-------------------------- |
| ctx | Context || Default go language context |
| reallocateContainer | ReallocateContainer || |
| Name | Type | Required | Description |
| :------------------ | :-------------------- | :------- | :-------------------------- |
| ctx | `Context` || Default go language context |
| reallocateContainer | `ReallocateContainer` || |

**Return Type**

Expand Down Expand Up @@ -61,9 +61,9 @@ Gets the health statuses of the running container

**Parameters**

| Name | Type | Required | Description |
| :--- | :------ | :------- | :-------------------------- |
| ctx | Context || Default go language context |
| Name | Type | Required | Description |
| :--- | :-------- | :------- | :-------------------------- |
| ctx | `Context` || Default go language context |

**Return Type**

Expand Down Expand Up @@ -99,9 +99,9 @@ Gets the identity token of the running container

**Parameters**

| Name | Type | Required | Description |
| :--- | :------ | :------- | :-------------------------- |
| ctx | Context || Default go language context |
| Name | Type | Required | Description |
| :--- | :-------- | :------- | :-------------------------- |
| ctx | `Context` || Default go language context |

**Return Type**

Expand Down
2 changes: 0 additions & 2 deletions internal/clients/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type RestClient[T any] struct {
}

func NewRestClient[T any](config saladcloudimdssdkconfig.Config) *RestClient[T] {
defaultHeadersHandler := handlers.NewDefaultHeadersHandler[T]()
retryHandler := handlers.NewRetryHandler[T]()
responseValidationHandler := handlers.NewResponseValidationHandler[T]()
unmarshalHandler := handlers.NewUnmarshalHandler[T]()
Expand All @@ -21,7 +20,6 @@ func NewRestClient[T any](config saladcloudimdssdkconfig.Config) *RestClient[T]
terminatingHandler := handlers.NewTerminatingHandler[T]()

handlers := handlers.BuildHandlerChain[T]().
AddHandler(defaultHeadersHandler).
AddHandler(retryHandler).
AddHandler(responseValidationHandler).
AddHandler(unmarshalHandler).
Expand Down
43 changes: 0 additions & 43 deletions internal/clients/rest/handlers/default_headers_handler.go

This file was deleted.

12 changes: 12 additions & 0 deletions internal/validation/validate_array_length.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
)

func validateArrayLength(field reflect.StructField, value reflect.Value) error {
if value.IsNil() {
return nil
}

kind := utils.GetReflectKind(value.Type())
if kind != reflect.Array && kind != reflect.Slice {
return nil
Expand All @@ -28,6 +32,10 @@ func validateArrayLength(field reflect.StructField, value reflect.Value) error {
}

func validateMinLength(field reflect.StructField, value reflect.Value) error {
if value.IsNil() {
return nil
}

minLength, found := field.Tag.Lookup("minLength")
if !found {
return nil
Expand All @@ -47,6 +55,10 @@ func validateMinLength(field reflect.StructField, value reflect.Value) error {
}

func validateMaxLength(field reflect.StructField, value reflect.Value) error {
if value.IsNil() {
return nil
}

maxLength, found := field.Tag.Lookup("maxLength")
if !found {
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/validation/validate_array_unique.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func validateArrayIsUnique(field reflect.StructField, value reflect.Value) error {
unique, found := field.Tag.Lookup("uniqueItems")
if !found || unique != "true" {
if !found || unique != "true" || value.IsNil() {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/validation/validate_max.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func validateMax(field reflect.StructField, value reflect.Value) error {
maxValue, found := field.Tag.Lookup("max")
if !found || maxValue == "" {
if !found || maxValue == "" || value.IsNil() {
return nil
}

Expand Down
6 changes: 1 addition & 5 deletions internal/validation/validate_min.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func validateMin(field reflect.StructField, value reflect.Value) error {
minValue, found := field.Tag.Lookup("min")
if !found || minValue == "" {
if !found || minValue == "" || value.IsNil() {
return nil
}

Expand All @@ -19,10 +19,6 @@ func validateMin(field reflect.StructField, value reflect.Value) error {
return err
}

if value.IsNil() {
return fmt.Errorf("field %s is required", field.Name)
}

val := utils.GetReflectValue(value)

if val.CanInt() {
Expand Down
2 changes: 1 addition & 1 deletion internal/validation/validate_multiple_of.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func validateMultipleOf(field reflect.StructField, value reflect.Value) error {
multipleOfValue, found := field.Tag.Lookup("multipleOf")
if !found || multipleOfValue == "" {
if !found || multipleOfValue == "" || value.IsNil() {
return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/metadata/metadata_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (api *MetadataService) ReallocateContainer(ctx context.Context, reallocateC
client := restClient.NewRestClient[any](config)

request := httptransport.NewRequest(ctx, "POST", "/v1/reallocate", config)
request.Headers["Content-Type"] = "application/json"

request.Body = reallocateContainer

Expand Down

0 comments on commit c78285e

Please sign in to comment.