Skip to content

Commit

Permalink
liblab SDK update for version v0.9.0-alpha.4
Browse files Browse the repository at this point in the history
  • Loading branch information
seniorquico committed Oct 5, 2024
1 parent 1c97e66 commit 124594e
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 124 deletions.
33 changes: 16 additions & 17 deletions .manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"liblabVersion": "2.4.0",
"date": "2024-09-17T04:36:05.118Z",
"liblabVersion": "2.5.1",
"date": "2024-10-05T04:00:45.117Z",
"config": {
"apiId": 1126,
"sdkName": "salad-cloud-imds-sdk",
"sdkVersion": "0.9.0-alpha.3",
"sdkVersion": "0.9.0-alpha.4",
"liblabVersion": "2",
"deliveryMethods": ["zip"],
"languages": ["java"],
Expand Down Expand Up @@ -33,7 +33,7 @@
"githubRepoName": "salad-cloud-imds-sdk-go",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.3",
"sdkVersion": "0.9.0-alpha.4",
"targetBranch": "main"
},
"java": {
Expand All @@ -57,11 +57,11 @@
"homepage": "https://github.com/saladtechnologies/salad-cloud-imds-sdk-java",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.3",
"sdkVersion": "0.9.0-alpha.4",
"targetBranch": "main"
},
"python": {
"alwaysInitializeOptionals": true,
"alwaysInitializeOptionals": false,
"classifiers": [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
Expand Down Expand Up @@ -100,7 +100,7 @@
"githubRepoName": "salad-cloud-imds-sdk-python",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.3",
"sdkVersion": "0.9.0-alpha.4",
"targetBranch": "main"
},
"typescript": {
Expand All @@ -123,8 +123,9 @@
"homepage": "https://github.com/saladtechnologies/salad-cloud-imds-sdk-javascript",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.3",
"targetBranch": "main"
"sdkVersion": "0.9.0-alpha.4",
"targetBranch": "main",
"generateEnumAs": "enum"
}
},
"publishing": {
Expand Down Expand Up @@ -155,7 +156,7 @@
},
"multiTenant": true,
"hooksLocation": {
"bucketKey": "7207/hooks.zip",
"bucketKey": "7538/hooks.zip",
"bucketName": "prod-liblab-api-stack-hooks"
},
"includeWatermark": false,
Expand Down Expand Up @@ -192,7 +193,7 @@
"httpLibrary": {
"name": "axios",
"packages": {
"axios": "^1.7.4"
"axios": "^1.7.7"
},
"languages": ["typescript"]
},
Expand All @@ -212,12 +213,8 @@
"src/main/java/com/salad/cloud/imdssdk/validation/validators/NumericValidator.java",
"src/main/java/com/salad/cloud/imdssdk/validation/validators/StringValidator.java",
"src/main/java/com/salad/cloud/imdssdk/validation/validators/Validator.java",
"src/main/java/com/salad/cloud/imdssdk/validation/validators/modelValidators/AbstractModelValidator.java",
"src/main/java/com/salad/cloud/imdssdk/validation/exceptions/ValidationException.java",
"src/main/java/com/salad/cloud/imdssdk/validation/annotation/Length.java",
"src/main/java/com/salad/cloud/imdssdk/validation/annotation/Max.java",
"src/main/java/com/salad/cloud/imdssdk/validation/annotation/Min.java",
"src/main/java/com/salad/cloud/imdssdk/validation/annotation/Pattern.java",
"src/main/java/com/salad/cloud/imdssdk/validation/annotation/Valid.java",
"src/main/java/com/salad/cloud/imdssdk/services/BaseService.java",
"src/main/java/com/salad/cloud/imdssdk/http/HttpMethod.java",
"src/main/java/com/salad/cloud/imdssdk/http/ModelConverter.java",
Expand Down Expand Up @@ -247,9 +244,11 @@
"src/main/java/com/salad/cloud/imdssdk/json/TypeUtils.java",
".devcontainer/devcontainer.json",
"example/pom.xml",
"example/setup.sh",
"example/run.sh",
"example/src/main/java/com/example/Main.java",
"example/.gitignore",
"src/main/java/com/salad/cloud/imdssdk/validation/validators/modelValidators/ReallocateContainerValidator.java",
"src/main/java/com/salad/cloud/imdssdk/validation/validators/modelValidators/ContainerTokenValidator.java",
"src/main/java/com/salad/cloud/imdssdk/models/ReallocateContainer.java",
"src/main/java/com/salad/cloud/imdssdk/models/ContainerToken.java",
"src/main/java/com/salad/cloud/imdssdk/services/MetadataService.java",
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SaladCloudImdsSdk Java SDK 0.9.0-alpha.3
# SaladCloudImdsSdk Java SDK 0.9.0-alpha.4

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.3`
- SDK version: `0.9.0-alpha.4`

## About the API

Expand Down Expand Up @@ -36,14 +36,14 @@ If you use Maven, place the following within the _dependency_ tag in your `pom.x
<dependency>
<groupId>com.salad.cloud</groupId>
<artifactId>imds-sdk</artifactId>
<version>0.9.0-alpha.3</version>
<version>0.9.0-alpha.4</version>
</dependency>
```

If you use Gradle, paste the next line inside the _dependencies_ block of your `build.gradle` file:

```Gradle
implementation group: com.salad.cloud, name: imds-sdk, version: 0.9.0-alpha.3
implementation group: com.salad.cloud, name: imds-sdk, version: 0.9.0-alpha.4
```

If you use JAR files, package the SDK by running the following command:
Expand Down
10 changes: 9 additions & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>com.salad.cloud</groupId>
<artifactId>imds-sdk</artifactId>
<version>0.9.0-alpha.3</version>
<version>0.9.0-alpha.4</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -73,6 +73,14 @@
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<mainClass>com.example.Main</mainClass>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
1 change: 1 addition & 0 deletions example/setup.sh → example/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ cd ../
mvn clean install
cd example
mvn clean install
mvn exec:java
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.salad.cloud</groupId>
<artifactId>imds-sdk</artifactId>
<version>0.9.0-alpha.3</version>
<version>0.9.0-alpha.4</version>

<!-- See https://central.sonatype.org/publish/requirements/#project-name-description-and-url -->
<name>${project.groupId}:${project.artifactId}</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.With;
import lombok.extern.jackson.Jacksonized;

/**
* Represents the health statuses of the running container.
*/
@Data
@Builder
@With
@ToString
@EqualsAndHashCode
@Jacksonized
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.salad.cloud.imdssdk.models;

import com.salad.cloud.imdssdk.validation.annotation.Length;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.With;
import lombok.extern.jackson.Jacksonized;

/**
* Represents the identity token of the running container.
*/
@Data
@Builder
@With
@ToString
@EqualsAndHashCode
@Jacksonized
Expand All @@ -22,6 +23,5 @@ public class ContainerToken {
* 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.
*/
@NonNull
@Length(min = 1, max = 1000)
private String jwt;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.salad.cloud.imdssdk.models;

import com.salad.cloud.imdssdk.validation.annotation.Length;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.With;
import lombok.extern.jackson.Jacksonized;

/**
* Represents a request to reallocate a container.
*/
@Data
@Builder
@With
@ToString
@EqualsAndHashCode
@Jacksonized
Expand All @@ -22,6 +23,5 @@ public class ReallocateContainer {
* The reason for reallocating the container. This value is reported to SaladCloud support for quality assurance of Salad Nodes.
*/
@NonNull
@Length(min = 1, max = 1000)
private String reason;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected Response execute(Request request) throws ApiException {
}
}

protected CompletableFuture<Response> executeAsync(Request request) throws ApiException {
protected CompletableFuture<Response> executeAsync(Request request) {
CompletableFuture<Response> future = new CompletableFuture<>();
this.httpClient.newCall(request)
.enqueue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import com.salad.cloud.imdssdk.models.ContainerStatus;
import com.salad.cloud.imdssdk.models.ContainerToken;
import com.salad.cloud.imdssdk.models.ReallocateContainer;
import com.salad.cloud.imdssdk.validation.ViolationAggregator;
import com.salad.cloud.imdssdk.validation.exceptions.ValidationException;
import com.salad.cloud.imdssdk.validation.validators.modelValidators.ReallocateContainerValidator;
import java.util.concurrent.CompletableFuture;
import lombok.NonNull;
import okhttp3.OkHttpClient;
Expand All @@ -29,7 +32,8 @@ public MetadataService(@NonNull OkHttpClient httpClient, String serverUrl) {
* @param reallocateContainer {@link ReallocateContainer} Request Body
* @return response of {@code Void}
*/
public void reallocateContainer(@NonNull ReallocateContainer reallocateContainer) throws ApiException {
public void reallocateContainer(@NonNull ReallocateContainer reallocateContainer)
throws ApiException, ValidationException {
Request request = this.buildReallocateContainerRequest(reallocateContainer);
this.execute(request);
}
Expand All @@ -41,14 +45,19 @@ public void reallocateContainer(@NonNull ReallocateContainer reallocateContainer
* @return response of {@code Void}
*/
public CompletableFuture<Void> reallocateContainerAsync(@NonNull ReallocateContainer reallocateContainer)
throws ApiException {
throws ApiException, ValidationException {
Request request = this.buildReallocateContainerRequest(reallocateContainer);
CompletableFuture<Response> response = this.executeAsync(request);

return response.thenApplyAsync(res -> null);
}

private Request buildReallocateContainerRequest(@NonNull ReallocateContainer reallocateContainer) {
private Request buildReallocateContainerRequest(@NonNull ReallocateContainer reallocateContainer)
throws ValidationException {
new ViolationAggregator()
.add(new ReallocateContainerValidator("reallocateContainer").validate(reallocateContainer))
.validateAll();

return new RequestBuilder(HttpMethod.POST, this.serverUrl, "v1/reallocate")
.setJsonContent(reallocateContainer)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ public class ViolationAggregator {

List<Violation> violations = new ArrayList<>();

public <T> ViolationAggregator add(AbstractValidator<T> validator, T value) {
Violation[] violations = validator.validate(value);
if (violations.length > 0) {
this.violations.addAll(Arrays.asList(violations));
}
public <T> ViolationAggregator add(Violation[] violations) {
this.violations.addAll(Arrays.asList(violations));
return this;
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 124594e

Please sign in to comment.