From 48a167c0c1ba9db3b2b8147bf064e005a0192cfa Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Wed, 8 Jan 2025 00:08:48 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.465.0 --- .gitignore | 1 + .speakeasy/gen.lock | 44 ++- .speakeasy/workflow.lock | 14 +- README.md | 6 +- RELEASES.md | 12 +- build.gradle | 21 +- codeSamples.yaml | 12 +- docs/models/operations/ResumeRoomRequest.md | 9 + docs/models/operations/ResumeRoomResponse.md | 11 + docs/models/shared/BuildV3.md | 1 + docs/models/shared/CreateRoomParams.md | 2 +- .../shared/CreatedBuildV3WithMultipartUrls.md | 1 + docs/models/shared/Deployment.md | 2 +- docs/models/shared/DeploymentV3.md | 2 +- docs/sdks/lobbiesv3/README.md | 1 + docs/sdks/logsv1/README.md | 1 + docs/sdks/metricsv1/README.md | 3 +- docs/sdks/processesv3/README.md | 1 + docs/sdks/roomsv2/README.md | 58 ++++ gen.yaml | 2 +- .../dev/hathora/cloud_sdk/HathoraCloud.java | 10 +- .../java/dev/hathora/cloud_sdk/MetricsV1.java | 2 +- .../java/dev/hathora/cloud_sdk/RoomsV2.java | 154 +++++++++++ .../hathora/cloud_sdk/SDKConfiguration.java | 4 +- .../cloud_sdk/models/operations/File.java | 2 +- .../models/operations/ResumeRoomRequest.java | 136 ++++++++++ .../operations/ResumeRoomRequestBuilder.java | 45 ++++ .../models/operations/ResumeRoomResponse.java | 252 ++++++++++++++++++ .../RunBuildDeprecatedRequestBody.java | 2 +- .../operations/RunBuildV2DeprecatedFile.java | 2 +- .../RunBuildV2DeprecatedRequestBody.java | 2 +- .../operations/SDKMethodInterfaces.java | 7 + .../cloud_sdk/models/shared/BuildStatus.java | 178 ++++++++++++- .../cloud_sdk/models/shared/BuildV3.java | 62 ++++- .../cloud_sdk/models/shared/CardBrand.java | 205 +++++++++++++- .../models/shared/CreateRoomParams.java | 18 ++ .../CreatedBuildV3WithMultipartUrls.java | 62 ++++- .../cloud_sdk/models/shared/Deployment.java | 12 +- .../shared/DeploymentV1TransportType.java | 173 +++++++++++- .../cloud_sdk/models/shared/DeploymentV3.java | 12 +- .../shared/DeprecatedProcessMetricName.java | 183 ++++++++++++- .../models/shared/FleetMetricName.java | 178 ++++++++++++- .../models/shared/InvoiceStatus.java | 173 +++++++++++- .../models/shared/LobbyVisibility.java | 173 +++++++++++- .../cloud_sdk/models/shared/OrgToken2.java | 163 ++++++++++- .../models/shared/OrgTokenStatus.java | 168 +++++++++++- .../cloud_sdk/models/shared/PlanName.java | 178 ++++++++++++- .../models/shared/ProcessMetricName.java | 185 ++++++++++++- .../models/shared/ProcessStatus.java | 188 ++++++++++++- .../cloud_sdk/models/shared/Region.java | 230 ++++++++++++++-- .../models/shared/RoomReadyStatus.java | 168 +++++++++++- .../cloud_sdk/models/shared/RoomStatus.java | 173 +++++++++++- .../cloud_sdk/models/shared/Scope.java | 235 ++++++++++++++-- .../shared/StartingConnectionInfoStatus.java | 163 ++++++++++- .../cloud_sdk/models/shared/Status.java | 163 ++++++++++- .../models/shared/TransportType.java | 173 +++++++++++- .../hathora/cloud_sdk/models/shared/Two.java | 163 ++++++++++- .../cloud_sdk/models/shared/UserRole.java | 173 +++++++++++- .../shared/VerificationEmailSuccess.java | 163 ++++++++++- .../cloud_sdk/utils/BigDecimalString.java | 30 +-- .../cloud_sdk/utils/BigIntegerString.java | 30 +-- .../hathora/cloud_sdk/utils/RequestBody.java | 32 ++- 62 files changed, 4725 insertions(+), 304 deletions(-) create mode 100644 docs/models/operations/ResumeRoomRequest.md create mode 100644 docs/models/operations/ResumeRoomResponse.md create mode 100644 src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequest.java create mode 100644 src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequestBuilder.java create mode 100644 src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomResponse.java diff --git a/.gitignore b/.gitignore index 2077465f..bfd32fd7 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.speakeasy/reports # Ignore IDE-specific configs .project .settings/ diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index cfc8d27b..603ef833 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 7b361cb9-7960-4aa9-aefb-1d3ff2bbe54b management: - docChecksum: d71c95af60ddb2e3da566c90fc29674d + docChecksum: 42b2f02d9a957fd022003d721821201e docVersion: 0.0.1 - speakeasyVersion: 1.453.10 - generationVersion: 2.474.15 - releaseVersion: 2.12.0 - configChecksum: 08990f6abf996bb8ea820f9a69053b81 + speakeasyVersion: 1.465.0 + generationVersion: 2.486.6 + releaseVersion: 2.13.0 + configChecksum: 439e6ab1fab1704e107a800109d342cd repoURL: https://github.com/hathora/cloud-sdk-java.git repoSubDirectory: . published: true @@ -14,7 +14,7 @@ features: java: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.1 - core: 3.33.1 + core: 3.33.4 deprecations: 2.81.1 downloadStreams: 0.1.1 flattening: 2.81.1 @@ -25,6 +25,7 @@ features: groups: 2.81.2 methodSecurity: 2.82.1 nullables: 0.1.0 + openEnums: 0.2.0 sdkHooks: 0.1.0 unions: 0.0.6 generatedFiles: @@ -239,6 +240,8 @@ generatedFiles: - docs/models/operations/RejectInviteResponse.md - docs/models/operations/RescindInviteRequest.md - docs/models/operations/RescindInviteResponse.md + - docs/models/operations/ResumeRoomRequest.md + - docs/models/operations/ResumeRoomResponse.md - docs/models/operations/RevokeOrgTokenRequest.md - docs/models/operations/RevokeOrgTokenResponse.md - docs/models/operations/RunBuildDeprecatedRequest.md @@ -772,6 +775,9 @@ generatedFiles: - src/main/java/dev/hathora/cloud_sdk/models/operations/RescindInviteRequest.java - src/main/java/dev/hathora/cloud_sdk/models/operations/RescindInviteRequestBuilder.java - src/main/java/dev/hathora/cloud_sdk/models/operations/RescindInviteResponse.java + - src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequest.java + - src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequestBuilder.java + - src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomResponse.java - src/main/java/dev/hathora/cloud_sdk/models/operations/RevokeOrgTokenRequest.java - src/main/java/dev/hathora/cloud_sdk/models/operations/RevokeOrgTokenRequestBuilder.java - src/main/java/dev/hathora/cloud_sdk/models/operations/RevokeOrgTokenResponse.java @@ -1153,7 +1159,8 @@ examples: responses: "401": application/json: {"message": ""} - "200": {} + "200": + application/json: {} GetUpcomingInvoiceItems: speakeasy-default-get-upcoming-invoice-items: parameters: @@ -1339,7 +1346,8 @@ examples: responses: "401": application/json: {"message": ""} - "200": {} + "200": + application/json: {} GetBuild: speakeasy-default-get-build: parameters: @@ -2207,7 +2215,8 @@ examples: responses: "404": application/json: {"message": ""} - "200": {} + "200": + application/json: {} "401": application/json: {"message": ""} GetMetricsDeprecated: @@ -2220,7 +2229,8 @@ examples: responses: "401": application/json: {"message": ""} - "200": {} + "200": + application/json: {} GetProcessMetrics: speakeasy-default-get-process-metrics: parameters: @@ -2231,7 +2241,8 @@ examples: responses: "401": application/json: {"message": ""} - "200": {} + "200": + application/json: {} GetUsageLimits: speakeasy-default-get-usage-limits: parameters: @@ -2254,4 +2265,15 @@ examples: application/json: true "401": application/json: {"message": ""} + ResumeRoom: + speakeasy-default-resume-room: + parameters: + path: + appId: "app-af469a92-5b45-4565-b3c4-b79878de67d2" + roomId: "2swovpy1fnunu" + responses: + "200": + application/json: {"additionalExposedPorts": [{"host": "1.proxy.hathora.dev", "name": "default", "port": 34567, "transportType": "tcp"}], "exposedPort": {"host": "1.proxy.hathora.dev", "name": "default", "port": 34567, "transportType": "tcp"}, "roomId": "2swovpy1fnunu", "status": "starting"} + "400": + application/json: {"message": ""} generatedTests: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index cb1e4fc7..c2f43116 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.453.10 +speakeasyVersion: 1.465.0 sources: java-source: sourceNamespace: java-source - sourceRevisionDigest: sha256:44176ea35f6e99ce7c64def78c0bf878556ecea6967a1187940739689c6cd32e - sourceBlobDigest: sha256:359ccd96250eaafa4b8dcf29095e596e43f7f5b7081b723eabaecedf060a6616 + sourceRevisionDigest: sha256:41ac8939fc7a1a5a6e938dd99c360bac2cb95a987aabbb356943de6d66e0912a + sourceBlobDigest: sha256:46ad59e03eb03392e0c897c123ed61adc2d9b22c09952ffe527e4ee3c110632e tags: - latest - - speakeasy-sdk-regen-1733875710 + - speakeasy-sdk-regen-1736294866 - 0.0.1 targets: hathora-java: source: java-source sourceNamespace: java-source - sourceRevisionDigest: sha256:44176ea35f6e99ce7c64def78c0bf878556ecea6967a1187940739689c6cd32e - sourceBlobDigest: sha256:359ccd96250eaafa4b8dcf29095e596e43f7f5b7081b723eabaecedf060a6616 + sourceRevisionDigest: sha256:41ac8939fc7a1a5a6e938dd99c360bac2cb95a987aabbb356943de6d66e0912a + sourceBlobDigest: sha256:46ad59e03eb03392e0c897c123ed61adc2d9b22c09952ffe527e4ee3c110632e codeSamplesNamespace: code-samples-java-hathora-java - codeSamplesRevisionDigest: sha256:75903bab92916a456dda04acb44a189547d3dea9f46187ab01a51b7ef999208a + codeSamplesRevisionDigest: sha256:99adf7dcd87d4b3d7e4d7589624865a6c13899a353d73501be8eadca42f25aac workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 58f21f76..1fd0a066 100755 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ The samples below show how a published SDK artifact is used: Gradle: ```groovy -implementation 'dev.hathora:cloud-sdk:2.12.0' +implementation 'dev.hathora:cloud-sdk:2.13.0' ``` Maven: @@ -44,7 +44,7 @@ Maven: dev.hathora cloud-sdk - 2.12.0 + 2.13.0 ``` @@ -298,6 +298,7 @@ public class Application { * [getConnectionInfo](docs/sdks/roomsv2/README.md#getconnectioninfo) - GetConnectionInfo * [getInactiveRoomsForProcess](docs/sdks/roomsv2/README.md#getinactiveroomsforprocess) - GetInactiveRoomsForProcess * [getRoomInfo](docs/sdks/roomsv2/README.md#getroominfo) - GetRoomInfo +* [resumeRoom](docs/sdks/roomsv2/README.md#resumeroom) - ResumeRoom * [~~suspendRoomV2Deprecated~~](docs/sdks/roomsv2/README.md#suspendroomv2deprecated) - SuspendRoomV2Deprecated :warning: **Deprecated** * [updateRoomConfig](docs/sdks/roomsv2/README.md#updateroomconfig) - UpdateRoomConfig @@ -603,6 +604,7 @@ public class Application { .visibility(LobbyVisibility.PRIVATE) .roomConfig("{\"name\":\"my-room\"}") .build()) + .appId("app-af469a92-5b45-4565-b3c4-b79878de67d2") .roomId("2swovpy1fnunu") .shortCode("LFG4") .build(); diff --git a/RELEASES.md b/RELEASES.md index 77cf5097..4ec34660 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -889,4 +889,14 @@ Based on: ### Generated - [java v2.12.0] . ### Releases -- [Maven Central v2.12.0] https://central.sonatype.com/artifact/dev.hathora/cloud-sdk/2.12.0 - . \ No newline at end of file +- [Maven Central v2.12.0] https://central.sonatype.com/artifact/dev.hathora/cloud-sdk/2.12.0 - . + +## 2025-01-08 00:07:42 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.465.0 (2.486.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [java v2.13.0] . +### Releases +- [Maven Central v2.13.0] https://central.sonatype.com/artifact/dev.hathora/cloud-sdk/2.13.0 - . \ No newline at end of file diff --git a/build.gradle b/build.gradle index a92dbb78..a73bf595 100644 --- a/build.gradle +++ b/build.gradle @@ -63,7 +63,7 @@ tasks.withType(Javadoc) { } group = "dev.hathora" -version = "2.12.0" +version = "2.13.0" sourcesJar { archiveBaseName = "cloud-sdk" @@ -101,7 +101,7 @@ publishing { maven(MavenPublication) { groupId = 'dev.hathora' artifactId = 'cloud-sdk' - version = '2.12.0' + version = '2.13.0' from components.java @@ -144,20 +144,19 @@ if (!project.hasProperty('skip.signing')) { } } + + dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' implementation 'org.java-websocket:Java-WebSocket:1.5.6' - api 'com.fasterxml.jackson.core:jackson-annotations:2.17.2' - implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2' - implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2' - implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2' + api 'com.fasterxml.jackson.core:jackson-annotations:2.18.2' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2' + implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2' + implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2' api('org.openapitools:jackson-databind-nullable:0.2.6') {exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'} - implementation 'org.apache.httpcomponents:httpclient:4.5.14' - implementation 'org.apache.httpcomponents:httpmime:4.5.14' - implementation 'commons-io:commons-io:2.15.1' + implementation 'org.apache.httpcomponents.client5:httpclient5:5.4.1' + implementation 'commons-io:commons-io:2.18.0' } - - apply from: 'build-extras.gradle' diff --git a/codeSamples.yaml b/codeSamples.yaml index 7d0f6244..16d958cd 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -176,7 +176,7 @@ actions: "x-codeSamples": - "lang": "java" "label": "CreateLobby" - "source": "package hello.world;\n\nimport dev.hathora.cloud_sdk.HathoraCloud;\nimport dev.hathora.cloud_sdk.models.errors.ApiError;\nimport dev.hathora.cloud_sdk.models.operations.CreateLobbyRequest;\nimport dev.hathora.cloud_sdk.models.operations.CreateLobbyResponse;\nimport dev.hathora.cloud_sdk.models.operations.CreateLobbySecurity;\nimport dev.hathora.cloud_sdk.models.shared.CreateLobbyV3Params;\nimport dev.hathora.cloud_sdk.models.shared.LobbyVisibility;\nimport dev.hathora.cloud_sdk.models.shared.Region;\nimport java.lang.Exception;\n\npublic class Application {\n\n public static void main(String[] args) throws ApiError, Exception {\n\n HathoraCloud sdk = HathoraCloud.builder()\n .orgId(\"org-6f706e83-0ec1-437a-9a46-7d4281eb2f39\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n CreateLobbyRequest req = CreateLobbyRequest.builder()\n .createLobbyV3Params(CreateLobbyV3Params.builder()\n .visibility(LobbyVisibility.PRIVATE)\n .region(Region.SEATTLE)\n .roomConfig(\"{\\\"name\\\":\\\"my-room\\\"}\")\n .build())\n .shortCode(\"LFG4\")\n .roomId(\"2swovpy1fnunu\")\n .build();\n\n CreateLobbyResponse res = sdk.lobbiesV3().createLobby()\n .request(req)\n .security(CreateLobbySecurity.builder()\n .playerAuth(\"\")\n .build())\n .call();\n\n if (res.lobbyV3().isPresent()) {\n // handle response\n }\n }\n}" + "source": "package hello.world;\n\nimport dev.hathora.cloud_sdk.HathoraCloud;\nimport dev.hathora.cloud_sdk.models.errors.ApiError;\nimport dev.hathora.cloud_sdk.models.operations.CreateLobbyRequest;\nimport dev.hathora.cloud_sdk.models.operations.CreateLobbyResponse;\nimport dev.hathora.cloud_sdk.models.operations.CreateLobbySecurity;\nimport dev.hathora.cloud_sdk.models.shared.CreateLobbyV3Params;\nimport dev.hathora.cloud_sdk.models.shared.LobbyVisibility;\nimport dev.hathora.cloud_sdk.models.shared.Region;\nimport java.lang.Exception;\n\npublic class Application {\n\n public static void main(String[] args) throws ApiError, Exception {\n\n HathoraCloud sdk = HathoraCloud.builder()\n .orgId(\"org-6f706e83-0ec1-437a-9a46-7d4281eb2f39\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n CreateLobbyRequest req = CreateLobbyRequest.builder()\n .createLobbyV3Params(CreateLobbyV3Params.builder()\n .visibility(LobbyVisibility.PRIVATE)\n .region(Region.SEATTLE)\n .roomConfig(\"{\\\"name\\\":\\\"my-room\\\"}\")\n .build())\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .shortCode(\"LFG4\")\n .roomId(\"2swovpy1fnunu\")\n .build();\n\n CreateLobbyResponse res = sdk.lobbiesV3().createLobby()\n .request(req)\n .security(CreateLobbySecurity.builder()\n .playerAuth(\"\")\n .build())\n .call();\n\n if (res.lobbyV3().isPresent()) {\n // handle response\n }\n }\n}" - target: $["paths"]["/lobby/v3/{appId}/info/roomid/{roomId}"]["get"] update: "x-codeSamples": @@ -200,7 +200,7 @@ actions: "x-codeSamples": - "lang": "java" "label": "GetLogsForProcess" - "source": "package hello.world;\n\nimport dev.hathora.cloud_sdk.HathoraCloud;\nimport dev.hathora.cloud_sdk.models.errors.ApiError;\nimport dev.hathora.cloud_sdk.models.operations.GetLogsForProcessRequest;\nimport dev.hathora.cloud_sdk.models.operations.GetLogsForProcessResponse;\nimport dev.hathora.cloud_sdk.models.shared.Security;\nimport java.lang.Exception;\n\npublic class Application {\n\n public static void main(String[] args) throws ApiError, Exception {\n\n HathoraCloud sdk = HathoraCloud.builder()\n .security(Security.builder()\n .hathoraDevToken(\"\")\n .build())\n .orgId(\"org-6f706e83-0ec1-437a-9a46-7d4281eb2f39\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n GetLogsForProcessRequest req = GetLogsForProcessRequest.builder()\n .processId(\"cbfcddd2-0006-43ae-996c-995fff7bed2e\")\n .tailLines(100)\n .build();\n\n GetLogsForProcessResponse res = sdk.logsV1().getLogsForProcess()\n .request(req)\n .call();\n\n if (res.responseStream().isPresent()) {\n // handle response\n }\n }\n}" + "source": "package hello.world;\n\nimport dev.hathora.cloud_sdk.HathoraCloud;\nimport dev.hathora.cloud_sdk.models.errors.ApiError;\nimport dev.hathora.cloud_sdk.models.operations.GetLogsForProcessRequest;\nimport dev.hathora.cloud_sdk.models.operations.GetLogsForProcessResponse;\nimport dev.hathora.cloud_sdk.models.shared.Security;\nimport java.lang.Exception;\n\npublic class Application {\n\n public static void main(String[] args) throws ApiError, Exception {\n\n HathoraCloud sdk = HathoraCloud.builder()\n .security(Security.builder()\n .hathoraDevToken(\"\")\n .build())\n .orgId(\"org-6f706e83-0ec1-437a-9a46-7d4281eb2f39\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n GetLogsForProcessRequest req = GetLogsForProcessRequest.builder()\n .processId(\"cbfcddd2-0006-43ae-996c-995fff7bed2e\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .tailLines(100)\n .build();\n\n GetLogsForProcessResponse res = sdk.logsV1().getLogsForProcess()\n .request(req)\n .call();\n\n if (res.responseStream().isPresent()) {\n // handle response\n }\n }\n}" - target: $["paths"]["/logs/v1/{appId}/process/{processId}/download"]["get"] update: "x-codeSamples": @@ -290,7 +290,7 @@ actions: "x-codeSamples": - "lang": "java" "label": "GetProcessMetrics" - "source": "package hello.world;\n\nimport dev.hathora.cloud_sdk.HathoraCloud;\nimport dev.hathora.cloud_sdk.models.errors.ApiError;\nimport dev.hathora.cloud_sdk.models.operations.GetProcessMetricsRequest;\nimport dev.hathora.cloud_sdk.models.operations.GetProcessMetricsResponse;\nimport dev.hathora.cloud_sdk.models.shared.Security;\nimport java.lang.Exception;\n\npublic class Application {\n\n public static void main(String[] args) throws ApiError, Exception {\n\n HathoraCloud sdk = HathoraCloud.builder()\n .security(Security.builder()\n .hathoraDevToken(\"\")\n .build())\n .orgId(\"org-6f706e83-0ec1-437a-9a46-7d4281eb2f39\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n GetProcessMetricsRequest req = GetProcessMetricsRequest.builder()\n .processId(\"cbfcddd2-0006-43ae-996c-995fff7bed2e\")\n .build();\n\n GetProcessMetricsResponse res = sdk.processesV3().getProcessMetrics()\n .request(req)\n .call();\n\n if (res.processMetricsData().isPresent()) {\n // handle response\n }\n }\n}" + "source": "package hello.world;\n\nimport dev.hathora.cloud_sdk.HathoraCloud;\nimport dev.hathora.cloud_sdk.models.errors.ApiError;\nimport dev.hathora.cloud_sdk.models.operations.GetProcessMetricsRequest;\nimport dev.hathora.cloud_sdk.models.operations.GetProcessMetricsResponse;\nimport dev.hathora.cloud_sdk.models.shared.Security;\nimport java.lang.Exception;\n\npublic class Application {\n\n public static void main(String[] args) throws ApiError, Exception {\n\n HathoraCloud sdk = HathoraCloud.builder()\n .security(Security.builder()\n .hathoraDevToken(\"\")\n .build())\n .orgId(\"org-6f706e83-0ec1-437a-9a46-7d4281eb2f39\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n GetProcessMetricsRequest req = GetProcessMetricsRequest.builder()\n .processId(\"cbfcddd2-0006-43ae-996c-995fff7bed2e\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n GetProcessMetricsResponse res = sdk.processesV3().getProcessMetrics()\n .request(req)\n .call();\n\n if (res.processMetricsData().isPresent()) {\n // handle response\n }\n }\n}" - target: $["paths"]["/processes/v3/apps/{appId}/processes/regions/{region}"]["post"] update: "x-codeSamples": @@ -345,6 +345,12 @@ actions: - "lang": "java" "label": "GetInactiveRoomsForProcess" "source": "package hello.world;\n\nimport dev.hathora.cloud_sdk.HathoraCloud;\nimport dev.hathora.cloud_sdk.models.errors.ApiError;\nimport dev.hathora.cloud_sdk.models.operations.GetInactiveRoomsForProcessResponse;\nimport dev.hathora.cloud_sdk.models.shared.Security;\nimport java.lang.Exception;\n\npublic class Application {\n\n public static void main(String[] args) throws ApiError, Exception {\n\n HathoraCloud sdk = HathoraCloud.builder()\n .security(Security.builder()\n .hathoraDevToken(\"\")\n .build())\n .orgId(\"org-6f706e83-0ec1-437a-9a46-7d4281eb2f39\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n GetInactiveRoomsForProcessResponse res = sdk.roomsV2().getInactiveRoomsForProcess()\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .processId(\"cbfcddd2-0006-43ae-996c-995fff7bed2e\")\n .call();\n\n if (res.roomWithoutAllocations().isPresent()) {\n // handle response\n }\n }\n}" + - target: $["paths"]["/rooms/v2/{appId}/resume/{roomId}"]["post"] + update: + "x-codeSamples": + - "lang": "java" + "label": "ResumeRoom" + "source": "package hello.world;\n\nimport dev.hathora.cloud_sdk.HathoraCloud;\nimport dev.hathora.cloud_sdk.models.errors.ApiError;\nimport dev.hathora.cloud_sdk.models.operations.ResumeRoomResponse;\nimport dev.hathora.cloud_sdk.models.shared.Security;\nimport java.lang.Exception;\n\npublic class Application {\n\n public static void main(String[] args) throws ApiError, Exception {\n\n HathoraCloud sdk = HathoraCloud.builder()\n .security(Security.builder()\n .hathoraDevToken(\"\")\n .build())\n .orgId(\"org-6f706e83-0ec1-437a-9a46-7d4281eb2f39\")\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .build();\n\n ResumeRoomResponse res = sdk.roomsV2().resumeRoom()\n .appId(\"app-af469a92-5b45-4565-b3c4-b79878de67d2\")\n .roomId(\"2swovpy1fnunu\")\n .call();\n\n if (res.connectionInfoV2().isPresent()) {\n // handle response\n }\n }\n}" - target: $["paths"]["/rooms/v2/{appId}/update/{roomId}"]["post"] update: "x-codeSamples": diff --git a/docs/models/operations/ResumeRoomRequest.md b/docs/models/operations/ResumeRoomRequest.md new file mode 100644 index 00000000..13f1d073 --- /dev/null +++ b/docs/models/operations/ResumeRoomRequest.md @@ -0,0 +1,9 @@ +# ResumeRoomRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | +| `appId` | *Optional\* | :heavy_minus_sign: | N/A | app-af469a92-5b45-4565-b3c4-b79878de67d2 | +| `roomId` | *String* | :heavy_check_mark: | N/A | 2swovpy1fnunu | \ No newline at end of file diff --git a/docs/models/operations/ResumeRoomResponse.md b/docs/models/operations/ResumeRoomResponse.md new file mode 100644 index 00000000..7aa04f26 --- /dev/null +++ b/docs/models/operations/ResumeRoomResponse.md @@ -0,0 +1,11 @@ +# ResumeRoomResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | +| `connectionInfoV2` | [Optional\](../../models/shared/ConnectionInfoV2.md) | :heavy_minus_sign: | Ok | +| `contentType` | *String* | :heavy_check_mark: | HTTP response content type for this operation | +| `statusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `rawResponse` | [HttpResponse\](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.html) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/docs/models/shared/BuildV3.md b/docs/models/shared/BuildV3.md index f7a50124..2a2bcbc0 100644 --- a/docs/models/shared/BuildV3.md +++ b/docs/models/shared/BuildV3.md @@ -16,5 +16,6 @@ A build represents a game server artifact and its associated metadata. | `finishedAt` | [OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) | :heavy_check_mark: | When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) finished executing. | | | `imageSize` | *long* | :heavy_check_mark: | The size (in bytes) of the Docker image built by Hathora. | | | `orgId` | *String* | :heavy_check_mark: | System generated unique identifier for an organization. Not guaranteed to have a specific format. | org-6f706e83-0ec1-437a-9a46-7d4281eb2f39 | +| `shareUrl` | *Optional\* | :heavy_minus_sign: | Url to view details, like build logs, of the build. | | | `startedAt` | [OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) | :heavy_check_mark: | When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. | | | `status` | [BuildStatus](../../models/shared/BuildStatus.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/docs/models/shared/CreateRoomParams.md b/docs/models/shared/CreateRoomParams.md index a4d19ab6..1a063397 100644 --- a/docs/models/shared/CreateRoomParams.md +++ b/docs/models/shared/CreateRoomParams.md @@ -5,7 +5,7 @@ | Field | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `clientIPs` | List\<*String*> | :heavy_minus_sign: | N/A | | +| `clientIPs` | List\<*String*> | :heavy_minus_sign: | An optional list of client IP addresses to whitelist for DDoS protection. | | | `deploymentId` | *Optional\* | :heavy_minus_sign: | System generated id for a deployment. | dep-6d4c6a71-2d75-4b42-94e1-f312f57f33c5 | | `region` | [Region](../../models/shared/Region.md) | :heavy_check_mark: | N/A | | | `roomConfig` | *Optional\* | :heavy_minus_sign: | Optional configuration parameters for the room. Can be any string including stringified JSON. It is accessible from the room via [`GetRoomInfo()`](https://hathora.dev/api#tag/RoomV2/operation/GetRoomInfo). | {"name":"my-room"} | \ No newline at end of file diff --git a/docs/models/shared/CreatedBuildV3WithMultipartUrls.md b/docs/models/shared/CreatedBuildV3WithMultipartUrls.md index 1e6040c9..ed3bccc4 100644 --- a/docs/models/shared/CreatedBuildV3WithMultipartUrls.md +++ b/docs/models/shared/CreatedBuildV3WithMultipartUrls.md @@ -18,6 +18,7 @@ A build represents a game server artifact and its associated metadata. | `imageSize` | *long* | :heavy_check_mark: | The size (in bytes) of the Docker image built by Hathora. | | | `maxChunkSize` | *double* | :heavy_check_mark: | N/A | | | `orgId` | *String* | :heavy_check_mark: | System generated unique identifier for an organization. Not guaranteed to have a specific format. | org-6f706e83-0ec1-437a-9a46-7d4281eb2f39 | +| `shareUrl` | *Optional\* | :heavy_minus_sign: | Url to view details, like build logs, of the build. | | | `startedAt` | [OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) | :heavy_check_mark: | When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. | | | `status` | [BuildStatus](../../models/shared/BuildStatus.md) | :heavy_check_mark: | N/A | | | `uploadParts` | List\<[BuildPart](../../models/shared/BuildPart.md)> | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/docs/models/shared/Deployment.md b/docs/models/shared/Deployment.md index 9347fda5..a3cff451 100644 --- a/docs/models/shared/Deployment.md +++ b/docs/models/shared/Deployment.md @@ -18,5 +18,5 @@ | `env` | List\<[ApplicationWithLatestDeploymentAndBuildEnv](../../models/shared/ApplicationWithLatestDeploymentAndBuildEnv.md)> | :heavy_check_mark: | The environment variable that our process will have access to at runtime. | | | `idleTimeoutEnabled` | *boolean* | :heavy_check_mark: | Option to shut down processes that have had no new connections or rooms
for five minutes. | | | `requestedCPU` | *double* | :heavy_check_mark: | The number of cores allocated to your process. | 0.5 | -| `requestedMemoryMB` | *double* | :heavy_check_mark: | The amount of memory allocated to your process. | 1024 | +| `requestedMemoryMB` | *double* | :heavy_check_mark: | The amount of memory allocated to your process. By default, this is capped
at 8192 MB, but can be increased further on the Enterprise tier. | 1024 | | `roomsPerProcess` | *int* | :heavy_check_mark: | Governs how many [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) can be scheduled in a process. | 3 | \ No newline at end of file diff --git a/docs/models/shared/DeploymentV3.md b/docs/models/shared/DeploymentV3.md index 14898053..a2f32e2f 100644 --- a/docs/models/shared/DeploymentV3.md +++ b/docs/models/shared/DeploymentV3.md @@ -17,5 +17,5 @@ | `env` | List\<[DeploymentV3Env](../../models/shared/DeploymentV3Env.md)> | :heavy_check_mark: | The environment variable that our process will have access to at runtime. | | | `idleTimeoutEnabled` | *boolean* | :heavy_check_mark: | Option to shut down processes that have had no new connections or rooms
for five minutes. | | | `requestedCPU` | *double* | :heavy_check_mark: | The number of cores allocated to your process. | 0.5 | -| `requestedMemoryMB` | *double* | :heavy_check_mark: | The amount of memory allocated to your process. | 1024 | +| `requestedMemoryMB` | *double* | :heavy_check_mark: | The amount of memory allocated to your process. By default, this is capped
at 8192 MB, but can be increased further on the Enterprise tier. | 1024 | | `roomsPerProcess` | *int* | :heavy_check_mark: | Governs how many [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) can be scheduled in a process. | 3 | \ No newline at end of file diff --git a/docs/sdks/lobbiesv3/README.md b/docs/sdks/lobbiesv3/README.md index 8382f2c4..dc9ff416 100644 --- a/docs/sdks/lobbiesv3/README.md +++ b/docs/sdks/lobbiesv3/README.md @@ -44,6 +44,7 @@ public class Application { .visibility(LobbyVisibility.PRIVATE) .roomConfig("{\"name\":\"my-room\"}") .build()) + .appId("app-af469a92-5b45-4565-b3c4-b79878de67d2") .roomId("2swovpy1fnunu") .shortCode("LFG4") .build(); diff --git a/docs/sdks/logsv1/README.md b/docs/sdks/logsv1/README.md index f4e23bdb..017502e1 100644 --- a/docs/sdks/logsv1/README.md +++ b/docs/sdks/logsv1/README.md @@ -95,6 +95,7 @@ public class Application { GetLogsForProcessRequest req = GetLogsForProcessRequest.builder() .processId("cbfcddd2-0006-43ae-996c-995fff7bed2e") + .appId("app-af469a92-5b45-4565-b3c4-b79878de67d2") .tailLines(100) .build(); diff --git a/docs/sdks/metricsv1/README.md b/docs/sdks/metricsv1/README.md index 69f40ef2..e42b93de 100644 --- a/docs/sdks/metricsv1/README.md +++ b/docs/sdks/metricsv1/README.md @@ -3,7 +3,7 @@ ## Overview -Operations to get metrics by [process](https://hathora.dev/docs/concepts/hathora-entities#process). We store 72 hours of metrics data. +Deprecated. Use [ProcessesV3#GetProcessMetrics](https://hathora.dev/api#tag/ProcessesV3/operation/GetProcessMetrics) to fetch metrics about a specific process. ### Available Operations @@ -41,6 +41,7 @@ public class Application { GetMetricsDeprecatedRequest req = GetMetricsDeprecatedRequest.builder() .processId("cbfcddd2-0006-43ae-996c-995fff7bed2e") + .appId("app-af469a92-5b45-4565-b3c4-b79878de67d2") .build(); GetMetricsDeprecatedResponse res = sdk.metricsV1().getMetricsDeprecated() diff --git a/docs/sdks/processesv3/README.md b/docs/sdks/processesv3/README.md index 38eb11ea..0038584d 100644 --- a/docs/sdks/processesv3/README.md +++ b/docs/sdks/processesv3/README.md @@ -223,6 +223,7 @@ public class Application { GetProcessMetricsRequest req = GetProcessMetricsRequest.builder() .processId("cbfcddd2-0006-43ae-996c-995fff7bed2e") + .appId("app-af469a92-5b45-4565-b3c4-b79878de67d2") .build(); GetProcessMetricsResponse res = sdk.processesV3().getProcessMetrics() diff --git a/docs/sdks/roomsv2/README.md b/docs/sdks/roomsv2/README.md index 909b3a86..5b9fdcea 100644 --- a/docs/sdks/roomsv2/README.md +++ b/docs/sdks/roomsv2/README.md @@ -11,6 +11,7 @@ * [getConnectionInfo](#getconnectioninfo) - GetConnectionInfo * [getInactiveRoomsForProcess](#getinactiveroomsforprocess) - GetInactiveRoomsForProcess * [getRoomInfo](#getroominfo) - GetRoomInfo +* [resumeRoom](#resumeroom) - ResumeRoom * [~~suspendRoomV2Deprecated~~](#suspendroomv2deprecated) - SuspendRoomV2Deprecated :warning: **Deprecated** * [updateRoomConfig](#updateroomconfig) - UpdateRoomConfig @@ -361,6 +362,63 @@ public class Application { | models/errors/ApiError | 401, 404, 422, 429 | application/json | | models/errors/SDKError | 4XX, 5XX | \*/\* | +## resumeRoom + +ResumeRoom + +### Example Usage + +```java +package hello.world; + +import dev.hathora.cloud_sdk.HathoraCloud; +import dev.hathora.cloud_sdk.models.errors.ApiError; +import dev.hathora.cloud_sdk.models.operations.ResumeRoomResponse; +import dev.hathora.cloud_sdk.models.shared.Security; +import java.lang.Exception; + +public class Application { + + public static void main(String[] args) throws ApiError, Exception { + + HathoraCloud sdk = HathoraCloud.builder() + .security(Security.builder() + .hathoraDevToken("") + .build()) + .appId("app-af469a92-5b45-4565-b3c4-b79878de67d2") + .orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39") + .build(); + + ResumeRoomResponse res = sdk.roomsV2().resumeRoom() + .appId("app-af469a92-5b45-4565-b3c4-b79878de67d2") + .roomId("2swovpy1fnunu") + .call(); + + if (res.connectionInfoV2().isPresent()) { + // handle response + } + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | +| `appId` | *Optional\* | :heavy_minus_sign: | N/A | app-af469a92-5b45-4565-b3c4-b79878de67d2 | +| `roomId` | *String* | :heavy_check_mark: | N/A | 2swovpy1fnunu | + +### Response + +**[ResumeRoomResponse](../../models/operations/ResumeRoomResponse.md)** + +### Errors + +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| models/errors/ApiError | 400, 401, 402, 404, 422, 429, 500 | application/json | +| models/errors/SDKError | 4XX, 5XX | \*/\* | + ## ~~suspendRoomV2Deprecated~~ Suspend a [room](https://hathora.dev/docs/concepts/hathora-entities#room). The room is unallocated from the process but can be rescheduled later using the same `roomId`. diff --git a/gen.yaml b/gen.yaml index 8677d9fc..0bea8011 100644 --- a/gen.yaml +++ b/gen.yaml @@ -13,7 +13,7 @@ generation: baseServerURL: "" flattenGlobalSecurity: true java: - version: 2.12.0 + version: 2.13.0 additionalDependencies: - testImplementation:org.junit.jupiter:junit-jupiter-api:5.8.1 - testRuntimeOnly:org.junit.jupiter:junit-jupiter-engine:5.8.1 diff --git a/src/main/java/dev/hathora/cloud_sdk/HathoraCloud.java b/src/main/java/dev/hathora/cloud_sdk/HathoraCloud.java index 726540ff..1486a64d 100644 --- a/src/main/java/dev/hathora/cloud_sdk/HathoraCloud.java +++ b/src/main/java/dev/hathora/cloud_sdk/HathoraCloud.java @@ -4,12 +4,12 @@ package dev.hathora.cloud_sdk; -import dev.hathora.cloud_sdk.models.operations.SDKMethodInterfaces.*; import dev.hathora.cloud_sdk.utils.HTTPClient; import dev.hathora.cloud_sdk.utils.RetryConfig; import dev.hathora.cloud_sdk.utils.SpeakeasyHTTPClient; import dev.hathora.cloud_sdk.utils.Utils; import java.lang.String; +import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -91,7 +91,7 @@ public class HathoraCloud { private final ManagementV1 managementV1; /** - * Operations to get metrics by [process](https://hathora.dev/docs/concepts/hathora-entities#process). We store 72 hours of metrics data. + * Deprecated. Use [ProcessesV3#GetProcessMetrics](https://hathora.dev/api#tag/ProcessesV3/operation/GetProcessMetrics) to fetch metrics about a specific process. */ private final MetricsV1 metricsV1; @@ -221,7 +221,7 @@ public ManagementV1 managementV1() { } /** - * Operations to get metrics by [process](https://hathora.dev/docs/concepts/hathora-entities#process). We store 72 hours of metrics data. + * Deprecated. Use [ProcessesV3#GetProcessMetrics](https://hathora.dev/api#tag/ProcessesV3/operation/GetProcessMetrics) to fetch metrics about a specific process. */ public MetricsV1 metricsV1() { return metricsV1; @@ -364,7 +364,7 @@ public Builder retryConfig(RetryConfig retryConfig) { */ public Builder appId(String appId) { if (!this.sdkConfiguration.globals.get("parameters").containsKey("pathParam")) { - this.sdkConfiguration.globals.get("parameters").put("pathParam", new java.util.HashMap<>()); + this.sdkConfiguration.globals.get("parameters").put("pathParam", new HashMap<>()); } this.sdkConfiguration.globals.get("parameters").get("pathParam").put("appId", appId); @@ -380,7 +380,7 @@ public Builder appId(String appId) { */ public Builder orgId(String orgId) { if (!this.sdkConfiguration.globals.get("parameters").containsKey("queryParam")) { - this.sdkConfiguration.globals.get("parameters").put("queryParam", new java.util.HashMap<>()); + this.sdkConfiguration.globals.get("parameters").put("queryParam", new HashMap<>()); } this.sdkConfiguration.globals.get("parameters").get("queryParam").put("orgId", orgId); diff --git a/src/main/java/dev/hathora/cloud_sdk/MetricsV1.java b/src/main/java/dev/hathora/cloud_sdk/MetricsV1.java index 637f9bad..0d473140 100644 --- a/src/main/java/dev/hathora/cloud_sdk/MetricsV1.java +++ b/src/main/java/dev/hathora/cloud_sdk/MetricsV1.java @@ -28,7 +28,7 @@ import java.util.Optional; /** - * Operations to get metrics by [process](https://hathora.dev/docs/concepts/hathora-entities#process). We store 72 hours of metrics data. + * Deprecated. Use [ProcessesV3#GetProcessMetrics](https://hathora.dev/api#tag/ProcessesV3/operation/GetProcessMetrics) to fetch metrics about a specific process. */ public class MetricsV1 implements MethodCallGetMetricsDeprecated { diff --git a/src/main/java/dev/hathora/cloud_sdk/RoomsV2.java b/src/main/java/dev/hathora/cloud_sdk/RoomsV2.java index ed092a55..fa760f57 100644 --- a/src/main/java/dev/hathora/cloud_sdk/RoomsV2.java +++ b/src/main/java/dev/hathora/cloud_sdk/RoomsV2.java @@ -25,6 +25,9 @@ import dev.hathora.cloud_sdk.models.operations.GetRoomInfoRequest; import dev.hathora.cloud_sdk.models.operations.GetRoomInfoRequestBuilder; import dev.hathora.cloud_sdk.models.operations.GetRoomInfoResponse; +import dev.hathora.cloud_sdk.models.operations.ResumeRoomRequest; +import dev.hathora.cloud_sdk.models.operations.ResumeRoomRequestBuilder; +import dev.hathora.cloud_sdk.models.operations.ResumeRoomResponse; import dev.hathora.cloud_sdk.models.operations.SDKMethodInterfaces.*; import dev.hathora.cloud_sdk.models.operations.SuspendRoomV2DeprecatedRequest; import dev.hathora.cloud_sdk.models.operations.SuspendRoomV2DeprecatedRequestBuilder; @@ -63,6 +66,7 @@ public class RoomsV2 implements MethodCallGetConnectionInfo, MethodCallGetInactiveRoomsForProcess, MethodCallGetRoomInfo, + MethodCallResumeRoom, MethodCallSuspendRoomV2Deprecated, MethodCallUpdateRoomConfig { @@ -998,6 +1002,156 @@ public GetRoomInfoResponse getRoomInfo( + /** + * ResumeRoom + * @return The call builder + */ + public ResumeRoomRequestBuilder resumeRoom() { + return new ResumeRoomRequestBuilder(this); + } + + /** + * ResumeRoom + * @param roomId + * @return The response from the API call + * @throws Exception if the API call fails + */ + public ResumeRoomResponse resumeRoom( + String roomId) throws Exception { + return resumeRoom(Optional.empty(), roomId); + } + + /** + * ResumeRoom + * @param appId + * @param roomId + * @return The response from the API call + * @throws Exception if the API call fails + */ + public ResumeRoomResponse resumeRoom( + Optional appId, + String roomId) throws Exception { + ResumeRoomRequest request = + ResumeRoomRequest + .builder() + .appId(appId) + .roomId(roomId) + .build(); + + String _baseUrl = this.sdkConfiguration.serverUrl; + String _url = Utils.generateURL( + ResumeRoomRequest.class, + _baseUrl, + "/rooms/v2/{appId}/resume/{roomId}", + request, this.sdkConfiguration.globals); + + HTTPRequest _req = new HTTPRequest(_url, "POST"); + _req.addHeader("Accept", "application/json") + .addHeader("user-agent", + SDKConfiguration.USER_AGENT); + + Optional _hookSecuritySource = this.sdkConfiguration.securitySource(); + Utils.configureSecurity(_req, + this.sdkConfiguration.securitySource.getSecurity()); + HTTPClient _client = this.sdkConfiguration.defaultClient; + HttpRequest _r = + sdkConfiguration.hooks() + .beforeRequest( + new BeforeRequestContextImpl( + "ResumeRoom", + Optional.of(List.of()), + _hookSecuritySource), + _req.build()); + HttpResponse _httpRes; + try { + _httpRes = _client.send(_r); + if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "402", "404", "422", "429", "4XX", "500", "5XX")) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "ResumeRoom", + Optional.of(List.of()), + _hookSecuritySource), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "ResumeRoom", + Optional.of(List.of()), + _hookSecuritySource), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "ResumeRoom", + Optional.of(List.of()), + _hookSecuritySource), + Optional.empty(), + Optional.of(_e)); + } + String _contentType = _httpRes + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ResumeRoomResponse.Builder _resBuilder = + ResumeRoomResponse + .builder() + .contentType(_contentType) + .statusCode(_httpRes.statusCode()) + .rawResponse(_httpRes); + + ResumeRoomResponse _res = _resBuilder.build(); + + if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) { + if (Utils.contentTypeMatches(_contentType, "application/json")) { + ConnectionInfoV2 _out = Utils.mapper().readValue( + Utils.toUtf8AndClose(_httpRes.body()), + new TypeReference() {}); + _res.withConnectionInfoV2(Optional.ofNullable(_out)); + return _res; + } else { + throw new SDKError( + _httpRes, + _httpRes.statusCode(), + "Unexpected content-type received: " + _contentType, + Utils.extractByteArrayFromBody(_httpRes)); + } + } + if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "402", "404", "422", "429", "500")) { + if (Utils.contentTypeMatches(_contentType, "application/json")) { + ApiError _out = Utils.mapper().readValue( + Utils.toUtf8AndClose(_httpRes.body()), + new TypeReference() {}); + throw _out; + } else { + throw new SDKError( + _httpRes, + _httpRes.statusCode(), + "Unexpected content-type received: " + _contentType, + Utils.extractByteArrayFromBody(_httpRes)); + } + } + if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX", "5XX")) { + // no content + throw new SDKError( + _httpRes, + _httpRes.statusCode(), + "API error occurred", + Utils.extractByteArrayFromBody(_httpRes)); + } + throw new SDKError( + _httpRes, + _httpRes.statusCode(), + "Unexpected status code received: " + _httpRes.statusCode(), + Utils.extractByteArrayFromBody(_httpRes)); + } + + + /** * SuspendRoomV2Deprecated * Suspend a [room](https://hathora.dev/docs/concepts/hathora-entities#room). The room is unallocated from the process but can be rescheduled later using the same `roomId`. diff --git a/src/main/java/dev/hathora/cloud_sdk/SDKConfiguration.java b/src/main/java/dev/hathora/cloud_sdk/SDKConfiguration.java index 769e6104..c82c3473 100644 --- a/src/main/java/dev/hathora/cloud_sdk/SDKConfiguration.java +++ b/src/main/java/dev/hathora/cloud_sdk/SDKConfiguration.java @@ -31,8 +31,8 @@ public String resolvedServerUrl() { public int serverIdx = 0; private static final String LANGUAGE = "java"; public static final String OPENAPI_DOC_VERSION = "0.0.1"; - public static final String SDK_VERSION = "2.12.0"; - public static final String GEN_VERSION = "2.474.15"; + public static final String SDK_VERSION = "2.13.0"; + public static final String GEN_VERSION = "2.486.6"; private static final String BASE_PACKAGE = "dev.hathora.cloud_sdk"; public static final String USER_AGENT = String.format("speakeasy-sdk/%s %s %s %s %s", diff --git a/src/main/java/dev/hathora/cloud_sdk/models/operations/File.java b/src/main/java/dev/hathora/cloud_sdk/models/operations/File.java index 2515b16e..2aacbb2f 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/operations/File.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/operations/File.java @@ -19,7 +19,7 @@ public class File { @SpeakeasyMetadata("multipartForm:content") private byte[] content; - @SpeakeasyMetadata("multipartForm:name=file") + @SpeakeasyMetadata("multipartForm:name=fileName") private String fileName; @JsonCreator diff --git a/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequest.java b/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequest.java new file mode 100644 index 00000000..cd76e037 --- /dev/null +++ b/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequest.java @@ -0,0 +1,136 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +package dev.hathora.cloud_sdk.models.operations; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import dev.hathora.cloud_sdk.utils.SpeakeasyMetadata; +import dev.hathora.cloud_sdk.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Objects; +import java.util.Optional; + + +public class ResumeRoomRequest { + + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=appId") + private Optional appId; + + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=roomId") + private String roomId; + + @JsonCreator + public ResumeRoomRequest( + Optional appId, + String roomId) { + Utils.checkNotNull(appId, "appId"); + Utils.checkNotNull(roomId, "roomId"); + this.appId = appId; + this.roomId = roomId; + } + + public ResumeRoomRequest( + String roomId) { + this(Optional.empty(), roomId); + } + + @JsonIgnore + public Optional appId() { + return appId; + } + + @JsonIgnore + public String roomId() { + return roomId; + } + + public final static Builder builder() { + return new Builder(); + } + + public ResumeRoomRequest withAppId(String appId) { + Utils.checkNotNull(appId, "appId"); + this.appId = Optional.ofNullable(appId); + return this; + } + + public ResumeRoomRequest withAppId(Optional appId) { + Utils.checkNotNull(appId, "appId"); + this.appId = appId; + return this; + } + + public ResumeRoomRequest withRoomId(String roomId) { + Utils.checkNotNull(roomId, "roomId"); + this.roomId = roomId; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResumeRoomRequest other = (ResumeRoomRequest) o; + return + Objects.deepEquals(this.appId, other.appId) && + Objects.deepEquals(this.roomId, other.roomId); + } + + @Override + public int hashCode() { + return Objects.hash( + appId, + roomId); + } + + @Override + public String toString() { + return Utils.toString(ResumeRoomRequest.class, + "appId", appId, + "roomId", roomId); + } + + public final static class Builder { + + private Optional appId = Optional.empty(); + + private String roomId; + + private Builder() { + // force use of static builder() method + } + + public Builder appId(String appId) { + Utils.checkNotNull(appId, "appId"); + this.appId = Optional.ofNullable(appId); + return this; + } + + public Builder appId(Optional appId) { + Utils.checkNotNull(appId, "appId"); + this.appId = appId; + return this; + } + + public Builder roomId(String roomId) { + Utils.checkNotNull(roomId, "roomId"); + this.roomId = roomId; + return this; + } + + public ResumeRoomRequest build() { + return new ResumeRoomRequest( + appId, + roomId); + } + } +} + diff --git a/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequestBuilder.java b/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequestBuilder.java new file mode 100644 index 00000000..9721fb35 --- /dev/null +++ b/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomRequestBuilder.java @@ -0,0 +1,45 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +package dev.hathora.cloud_sdk.models.operations; + +import dev.hathora.cloud_sdk.utils.Utils; +import java.lang.String; +import java.util.Optional; + +public class ResumeRoomRequestBuilder { + + private Optional appId = Optional.empty(); + private String roomId; + private final SDKMethodInterfaces.MethodCallResumeRoom sdk; + + public ResumeRoomRequestBuilder(SDKMethodInterfaces.MethodCallResumeRoom sdk) { + this.sdk = sdk; + } + + public ResumeRoomRequestBuilder appId(String appId) { + Utils.checkNotNull(appId, "appId"); + this.appId = Optional.of(appId); + return this; + } + + public ResumeRoomRequestBuilder appId(Optional appId) { + Utils.checkNotNull(appId, "appId"); + this.appId = appId; + return this; + } + + public ResumeRoomRequestBuilder roomId(String roomId) { + Utils.checkNotNull(roomId, "roomId"); + this.roomId = roomId; + return this; + } + + public ResumeRoomResponse call() throws Exception { + + return sdk.resumeRoom( + appId, + roomId); + } +} diff --git a/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomResponse.java b/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomResponse.java new file mode 100644 index 00000000..03ff728a --- /dev/null +++ b/src/main/java/dev/hathora/cloud_sdk/models/operations/ResumeRoomResponse.java @@ -0,0 +1,252 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +package dev.hathora.cloud_sdk.models.operations; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import dev.hathora.cloud_sdk.models.shared.ConnectionInfoV2; +import dev.hathora.cloud_sdk.utils.Response; +import dev.hathora.cloud_sdk.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Objects; +import java.util.Optional; + + +public class ResumeRoomResponse implements Response { + + /** + * Ok + */ + private Optional connectionInfoV2; + + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + @JsonCreator + public ResumeRoomResponse( + Optional connectionInfoV2, + String contentType, + int statusCode, + HttpResponse rawResponse) { + Utils.checkNotNull(connectionInfoV2, "connectionInfoV2"); + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + this.connectionInfoV2 = connectionInfoV2; + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + } + + public ResumeRoomResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(Optional.empty(), contentType, statusCode, rawResponse); + } + + /** + * Ok + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional connectionInfoV2() { + return (Optional) connectionInfoV2; + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + public final static Builder builder() { + return new Builder(); + } + + /** + * Ok + */ + public ResumeRoomResponse withConnectionInfoV2(ConnectionInfoV2 connectionInfoV2) { + Utils.checkNotNull(connectionInfoV2, "connectionInfoV2"); + this.connectionInfoV2 = Optional.ofNullable(connectionInfoV2); + return this; + } + + /** + * Ok + */ + public ResumeRoomResponse withConnectionInfoV2(Optional connectionInfoV2) { + Utils.checkNotNull(connectionInfoV2, "connectionInfoV2"); + this.connectionInfoV2 = connectionInfoV2; + return this; + } + + /** + * HTTP response content type for this operation + */ + public ResumeRoomResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public ResumeRoomResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public ResumeRoomResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResumeRoomResponse other = (ResumeRoomResponse) o; + return + Objects.deepEquals(this.connectionInfoV2, other.connectionInfoV2) && + Objects.deepEquals(this.contentType, other.contentType) && + Objects.deepEquals(this.statusCode, other.statusCode) && + Objects.deepEquals(this.rawResponse, other.rawResponse); + } + + @Override + public int hashCode() { + return Objects.hash( + connectionInfoV2, + contentType, + statusCode, + rawResponse); + } + + @Override + public String toString() { + return Utils.toString(ResumeRoomResponse.class, + "connectionInfoV2", connectionInfoV2, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse); + } + + public final static class Builder { + + private Optional connectionInfoV2 = Optional.empty(); + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Builder() { + // force use of static builder() method + } + + /** + * Ok + */ + public Builder connectionInfoV2(ConnectionInfoV2 connectionInfoV2) { + Utils.checkNotNull(connectionInfoV2, "connectionInfoV2"); + this.connectionInfoV2 = Optional.ofNullable(connectionInfoV2); + return this; + } + + /** + * Ok + */ + public Builder connectionInfoV2(Optional connectionInfoV2) { + Utils.checkNotNull(connectionInfoV2, "connectionInfoV2"); + this.connectionInfoV2 = connectionInfoV2; + return this; + } + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + public ResumeRoomResponse build() { + return new ResumeRoomResponse( + connectionInfoV2, + contentType, + statusCode, + rawResponse); + } + } +} + diff --git a/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildDeprecatedRequestBody.java b/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildDeprecatedRequestBody.java index 75ad32c6..a7d14f89 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildDeprecatedRequestBody.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildDeprecatedRequestBody.java @@ -16,7 +16,7 @@ public class RunBuildDeprecatedRequestBody { - @SpeakeasyMetadata("multipartForm:file") + @SpeakeasyMetadata("multipartForm:file,name=file") private File file; @JsonCreator diff --git a/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildV2DeprecatedFile.java b/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildV2DeprecatedFile.java index 00594c76..86558a47 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildV2DeprecatedFile.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildV2DeprecatedFile.java @@ -19,7 +19,7 @@ public class RunBuildV2DeprecatedFile { @SpeakeasyMetadata("multipartForm:content") private byte[] content; - @SpeakeasyMetadata("multipartForm:name=file") + @SpeakeasyMetadata("multipartForm:name=fileName") private String fileName; @JsonCreator diff --git a/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildV2DeprecatedRequestBody.java b/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildV2DeprecatedRequestBody.java index 26538ff1..390469ec 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildV2DeprecatedRequestBody.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/operations/RunBuildV2DeprecatedRequestBody.java @@ -18,7 +18,7 @@ public class RunBuildV2DeprecatedRequestBody { - @SpeakeasyMetadata("multipartForm:file") + @SpeakeasyMetadata("multipartForm:file,name=file") private Optional file; @JsonCreator diff --git a/src/main/java/dev/hathora/cloud_sdk/models/operations/SDKMethodInterfaces.java b/src/main/java/dev/hathora/cloud_sdk/models/operations/SDKMethodInterfaces.java index d26eee22..f7804083 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/operations/SDKMethodInterfaces.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/operations/SDKMethodInterfaces.java @@ -779,6 +779,13 @@ GetRoomInfoResponse getRoomInfo( } + public interface MethodCallResumeRoom { + ResumeRoomResponse resumeRoom( + Optional appId, + String roomId) throws Exception; + } + + public interface MethodCallSuspendRoomV2Deprecated { SuspendRoomV2DeprecatedResponse suspendRoomV2Deprecated( Optional appId, diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/BuildStatus.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/BuildStatus.java index 869ddfc9..496a3046 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/BuildStatus.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/BuildStatus.java @@ -4,23 +4,185 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = BuildStatus._Deserializer.class) +@JsonSerialize(using = BuildStatus._Serializer.class) +public class BuildStatus { -public enum BuildStatus { - CREATED("created"), - RUNNING("running"), - SUCCEEDED("succeeded"), - FAILED("failed"); + public static final BuildStatus CREATED = new BuildStatus("created"); + public static final BuildStatus RUNNING = new BuildStatus("running"); + public static final BuildStatus SUCCEEDED = new BuildStatus("succeeded"); + public static final BuildStatus FAILED = new BuildStatus("failed"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private BuildStatus(String value) { this.value = value; } - + + /** + * Returns a BuildStatus with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as BuildStatus + */ + public static BuildStatus of(String value) { + synchronized (BuildStatus.class) { + return values.computeIfAbsent(value, v -> new BuildStatus(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BuildStatus other = (BuildStatus) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "BuildStatus [value=" + value + "]"; + } + + // return an array just like an enum + public static BuildStatus[] values() { + synchronized (BuildStatus.class) { + return values.values().toArray(new BuildStatus[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("created", CREATED); + map.put("running", RUNNING); + map.put("succeeded", SUCCEEDED); + map.put("failed", FAILED); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("created", BuildStatusEnum.CREATED); + map.put("running", BuildStatusEnum.RUNNING); + map.put("succeeded", BuildStatusEnum.SUCCEEDED); + map.put("failed", BuildStatusEnum.FAILED); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(BuildStatus.class); + } + + @Override + public void serialize(BuildStatus value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(BuildStatus.class); + } + + @Override + public BuildStatus deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return BuildStatus.of(v); + } + } + + public enum BuildStatusEnum { + + CREATED("created"), + RUNNING("running"), + SUCCEEDED("succeeded"), + FAILED("failed"),; + + private final String value; + + private BuildStatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/BuildV3.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/BuildV3.java index a28a47ed..b5ba885b 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/BuildV3.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/BuildV3.java @@ -76,6 +76,13 @@ public class BuildV3 { @JsonProperty("orgId") private String orgId; + /** + * Url to view details, like build logs, of the build. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("shareUrl") + private Optional shareUrl; + /** * When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. */ @@ -97,6 +104,7 @@ public BuildV3( @JsonProperty("finishedAt") Optional finishedAt, @JsonProperty("imageSize") long imageSize, @JsonProperty("orgId") String orgId, + @JsonProperty("shareUrl") Optional shareUrl, @JsonProperty("startedAt") Optional startedAt, @JsonProperty("status") BuildStatus status) { Utils.checkNotNull(buildId, "buildId"); @@ -108,6 +116,7 @@ public BuildV3( Utils.checkNotNull(finishedAt, "finishedAt"); Utils.checkNotNull(imageSize, "imageSize"); Utils.checkNotNull(orgId, "orgId"); + Utils.checkNotNull(shareUrl, "shareUrl"); Utils.checkNotNull(startedAt, "startedAt"); Utils.checkNotNull(status, "status"); this.buildId = buildId; @@ -119,6 +128,7 @@ public BuildV3( this.finishedAt = finishedAt; this.imageSize = imageSize; this.orgId = orgId; + this.shareUrl = shareUrl; this.startedAt = startedAt; this.status = status; } @@ -130,7 +140,7 @@ public BuildV3( long imageSize, String orgId, BuildStatus status) { - this(buildId, Optional.empty(), Optional.empty(), createdAt, createdBy, Optional.empty(), Optional.empty(), imageSize, orgId, Optional.empty(), status); + this(buildId, Optional.empty(), Optional.empty(), createdAt, createdBy, Optional.empty(), Optional.empty(), imageSize, orgId, Optional.empty(), Optional.empty(), status); } /** @@ -199,6 +209,14 @@ public String orgId() { return orgId; } + /** + * Url to view details, like build logs, of the build. + */ + @JsonIgnore + public Optional shareUrl() { + return shareUrl; + } + /** * When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. */ @@ -324,6 +342,24 @@ public BuildV3 withOrgId(String orgId) { return this; } + /** + * Url to view details, like build logs, of the build. + */ + public BuildV3 withShareUrl(String shareUrl) { + Utils.checkNotNull(shareUrl, "shareUrl"); + this.shareUrl = Optional.ofNullable(shareUrl); + return this; + } + + /** + * Url to view details, like build logs, of the build. + */ + public BuildV3 withShareUrl(Optional shareUrl) { + Utils.checkNotNull(shareUrl, "shareUrl"); + this.shareUrl = shareUrl; + return this; + } + /** * When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. */ @@ -367,6 +403,7 @@ public boolean equals(java.lang.Object o) { Objects.deepEquals(this.finishedAt, other.finishedAt) && Objects.deepEquals(this.imageSize, other.imageSize) && Objects.deepEquals(this.orgId, other.orgId) && + Objects.deepEquals(this.shareUrl, other.shareUrl) && Objects.deepEquals(this.startedAt, other.startedAt) && Objects.deepEquals(this.status, other.status); } @@ -383,6 +420,7 @@ public int hashCode() { finishedAt, imageSize, orgId, + shareUrl, startedAt, status); } @@ -399,6 +437,7 @@ public String toString() { "finishedAt", finishedAt, "imageSize", imageSize, "orgId", orgId, + "shareUrl", shareUrl, "startedAt", startedAt, "status", status); } @@ -423,6 +462,8 @@ public final static class Builder { private String orgId; + private Optional shareUrl = Optional.empty(); + private Optional startedAt = Optional.empty(); private BuildStatus status; @@ -539,6 +580,24 @@ public Builder orgId(String orgId) { return this; } + /** + * Url to view details, like build logs, of the build. + */ + public Builder shareUrl(String shareUrl) { + Utils.checkNotNull(shareUrl, "shareUrl"); + this.shareUrl = Optional.ofNullable(shareUrl); + return this; + } + + /** + * Url to view details, like build logs, of the build. + */ + public Builder shareUrl(Optional shareUrl) { + Utils.checkNotNull(shareUrl, "shareUrl"); + this.shareUrl = shareUrl; + return this; + } + /** * When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. */ @@ -574,6 +633,7 @@ public BuildV3 build() { finishedAt, imageSize, orgId, + shareUrl, startedAt, status); } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/CardBrand.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/CardBrand.java index 2d10be70..97f69d5e 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/CardBrand.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/CardBrand.java @@ -4,28 +4,205 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = CardBrand._Deserializer.class) +@JsonSerialize(using = CardBrand._Serializer.class) +public class CardBrand { + + public static final CardBrand AMEX = new CardBrand("amex"); + public static final CardBrand CARTES_BANCAIRES = new CardBrand("cartes_bancaires"); + public static final CardBrand DINERS = new CardBrand("diners"); + public static final CardBrand DISCOVER = new CardBrand("discover"); + public static final CardBrand JCB = new CardBrand("jcb"); + public static final CardBrand MASTERCARD = new CardBrand("mastercard"); + public static final CardBrand VISA = new CardBrand("visa"); + public static final CardBrand UNIONPAY = new CardBrand("unionpay"); + public static final CardBrand CARD = new CardBrand("card"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); -public enum CardBrand { - AMEX("amex"), - CARTES_BANCAIRES("cartes_bancaires"), - DINERS("diners"), - DISCOVER("discover"), - JCB("jcb"), - MASTERCARD("mastercard"), - VISA("visa"), - UNIONPAY("unionpay"), - CARD("card"); - - @JsonValue private final String value; private CardBrand(String value) { this.value = value; } - + + /** + * Returns a CardBrand with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as CardBrand + */ + public static CardBrand of(String value) { + synchronized (CardBrand.class) { + return values.computeIfAbsent(value, v -> new CardBrand(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CardBrand other = (CardBrand) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "CardBrand [value=" + value + "]"; + } + + // return an array just like an enum + public static CardBrand[] values() { + synchronized (CardBrand.class) { + return values.values().toArray(new CardBrand[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("amex", AMEX); + map.put("cartes_bancaires", CARTES_BANCAIRES); + map.put("diners", DINERS); + map.put("discover", DISCOVER); + map.put("jcb", JCB); + map.put("mastercard", MASTERCARD); + map.put("visa", VISA); + map.put("unionpay", UNIONPAY); + map.put("card", CARD); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("amex", CardBrandEnum.AMEX); + map.put("cartes_bancaires", CardBrandEnum.CARTES_BANCAIRES); + map.put("diners", CardBrandEnum.DINERS); + map.put("discover", CardBrandEnum.DISCOVER); + map.put("jcb", CardBrandEnum.JCB); + map.put("mastercard", CardBrandEnum.MASTERCARD); + map.put("visa", CardBrandEnum.VISA); + map.put("unionpay", CardBrandEnum.UNIONPAY); + map.put("card", CardBrandEnum.CARD); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(CardBrand.class); + } + + @Override + public void serialize(CardBrand value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(CardBrand.class); + } + + @Override + public CardBrand deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return CardBrand.of(v); + } + } + + public enum CardBrandEnum { + + AMEX("amex"), + CARTES_BANCAIRES("cartes_bancaires"), + DINERS("diners"), + DISCOVER("discover"), + JCB("jcb"), + MASTERCARD("mastercard"), + VISA("visa"), + UNIONPAY("unionpay"), + CARD("card"),; + + private final String value; + + private CardBrandEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/CreateRoomParams.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/CreateRoomParams.java index 67b11586..b1427492 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/CreateRoomParams.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/CreateRoomParams.java @@ -21,6 +21,9 @@ public class CreateRoomParams { + /** + * An optional list of client IP addresses to whitelist for DDoS protection. + */ @JsonInclude(Include.NON_ABSENT) @JsonProperty("clientIPs") private Optional> clientIPs; @@ -63,6 +66,9 @@ public CreateRoomParams( this(Optional.empty(), Optional.empty(), region, Optional.empty()); } + /** + * An optional list of client IP addresses to whitelist for DDoS protection. + */ @SuppressWarnings("unchecked") @JsonIgnore public Optional> clientIPs() { @@ -94,12 +100,18 @@ public final static Builder builder() { return new Builder(); } + /** + * An optional list of client IP addresses to whitelist for DDoS protection. + */ public CreateRoomParams withClientIPs(List clientIPs) { Utils.checkNotNull(clientIPs, "clientIPs"); this.clientIPs = Optional.ofNullable(clientIPs); return this; } + /** + * An optional list of client IP addresses to whitelist for DDoS protection. + */ public CreateRoomParams withClientIPs(Optional> clientIPs) { Utils.checkNotNull(clientIPs, "clientIPs"); this.clientIPs = clientIPs; @@ -196,12 +208,18 @@ private Builder() { // force use of static builder() method } + /** + * An optional list of client IP addresses to whitelist for DDoS protection. + */ public Builder clientIPs(List clientIPs) { Utils.checkNotNull(clientIPs, "clientIPs"); this.clientIPs = Optional.ofNullable(clientIPs); return this; } + /** + * An optional list of client IP addresses to whitelist for DDoS protection. + */ public Builder clientIPs(Optional> clientIPs) { Utils.checkNotNull(clientIPs, "clientIPs"); this.clientIPs = clientIPs; diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/CreatedBuildV3WithMultipartUrls.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/CreatedBuildV3WithMultipartUrls.java index 2e315fb7..faae081e 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/CreatedBuildV3WithMultipartUrls.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/CreatedBuildV3WithMultipartUrls.java @@ -84,6 +84,13 @@ public class CreatedBuildV3WithMultipartUrls { @JsonProperty("orgId") private String orgId; + /** + * Url to view details, like build logs, of the build. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("shareUrl") + private Optional shareUrl; + /** * When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. */ @@ -110,6 +117,7 @@ public CreatedBuildV3WithMultipartUrls( @JsonProperty("imageSize") long imageSize, @JsonProperty("maxChunkSize") double maxChunkSize, @JsonProperty("orgId") String orgId, + @JsonProperty("shareUrl") Optional shareUrl, @JsonProperty("startedAt") Optional startedAt, @JsonProperty("status") BuildStatus status, @JsonProperty("uploadParts") List uploadParts) { @@ -124,6 +132,7 @@ public CreatedBuildV3WithMultipartUrls( Utils.checkNotNull(imageSize, "imageSize"); Utils.checkNotNull(maxChunkSize, "maxChunkSize"); Utils.checkNotNull(orgId, "orgId"); + Utils.checkNotNull(shareUrl, "shareUrl"); Utils.checkNotNull(startedAt, "startedAt"); Utils.checkNotNull(status, "status"); Utils.checkNotNull(uploadParts, "uploadParts"); @@ -138,6 +147,7 @@ public CreatedBuildV3WithMultipartUrls( this.imageSize = imageSize; this.maxChunkSize = maxChunkSize; this.orgId = orgId; + this.shareUrl = shareUrl; this.startedAt = startedAt; this.status = status; this.uploadParts = uploadParts; @@ -153,7 +163,7 @@ public CreatedBuildV3WithMultipartUrls( String orgId, BuildStatus status, List uploadParts) { - this(buildId, Optional.empty(), completeUploadPostRequestUrl, Optional.empty(), createdAt, createdBy, Optional.empty(), Optional.empty(), imageSize, maxChunkSize, orgId, Optional.empty(), status, uploadParts); + this(buildId, Optional.empty(), completeUploadPostRequestUrl, Optional.empty(), createdAt, createdBy, Optional.empty(), Optional.empty(), imageSize, maxChunkSize, orgId, Optional.empty(), Optional.empty(), status, uploadParts); } /** @@ -232,6 +242,14 @@ public String orgId() { return orgId; } + /** + * Url to view details, like build logs, of the build. + */ + @JsonIgnore + public Optional shareUrl() { + return shareUrl; + } + /** * When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. */ @@ -374,6 +392,24 @@ public CreatedBuildV3WithMultipartUrls withOrgId(String orgId) { return this; } + /** + * Url to view details, like build logs, of the build. + */ + public CreatedBuildV3WithMultipartUrls withShareUrl(String shareUrl) { + Utils.checkNotNull(shareUrl, "shareUrl"); + this.shareUrl = Optional.ofNullable(shareUrl); + return this; + } + + /** + * Url to view details, like build logs, of the build. + */ + public CreatedBuildV3WithMultipartUrls withShareUrl(Optional shareUrl) { + Utils.checkNotNull(shareUrl, "shareUrl"); + this.shareUrl = shareUrl; + return this; + } + /** * When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. */ @@ -425,6 +461,7 @@ public boolean equals(java.lang.Object o) { Objects.deepEquals(this.imageSize, other.imageSize) && Objects.deepEquals(this.maxChunkSize, other.maxChunkSize) && Objects.deepEquals(this.orgId, other.orgId) && + Objects.deepEquals(this.shareUrl, other.shareUrl) && Objects.deepEquals(this.startedAt, other.startedAt) && Objects.deepEquals(this.status, other.status) && Objects.deepEquals(this.uploadParts, other.uploadParts); @@ -444,6 +481,7 @@ public int hashCode() { imageSize, maxChunkSize, orgId, + shareUrl, startedAt, status, uploadParts); @@ -463,6 +501,7 @@ public String toString() { "imageSize", imageSize, "maxChunkSize", maxChunkSize, "orgId", orgId, + "shareUrl", shareUrl, "startedAt", startedAt, "status", status, "uploadParts", uploadParts); @@ -492,6 +531,8 @@ public final static class Builder { private String orgId; + private Optional shareUrl = Optional.empty(); + private Optional startedAt = Optional.empty(); private BuildStatus status; @@ -622,6 +663,24 @@ public Builder orgId(String orgId) { return this; } + /** + * Url to view details, like build logs, of the build. + */ + public Builder shareUrl(String shareUrl) { + Utils.checkNotNull(shareUrl, "shareUrl"); + this.shareUrl = Optional.ofNullable(shareUrl); + return this; + } + + /** + * Url to view details, like build logs, of the build. + */ + public Builder shareUrl(Optional shareUrl) { + Utils.checkNotNull(shareUrl, "shareUrl"); + this.shareUrl = shareUrl; + return this; + } + /** * When [`RunBuild()`](https://hathora.dev/api#tag/BuildV2/operation/RunBuild) is called. */ @@ -665,6 +724,7 @@ public CreatedBuildV3WithMultipartUrls build() { imageSize, maxChunkSize, orgId, + shareUrl, startedAt, status, uploadParts); diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/Deployment.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/Deployment.java index 71596e02..bfb9d29f 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/Deployment.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/Deployment.java @@ -103,7 +103,8 @@ public class Deployment { private double requestedCPU; /** - * The amount of memory allocated to your process. + * The amount of memory allocated to your process. By default, this is capped + * at 8192 MB, but can be increased further on the Enterprise tier. */ @JsonProperty("requestedMemoryMB") private double requestedMemoryMB; @@ -283,7 +284,8 @@ public double requestedCPU() { } /** - * The amount of memory allocated to your process. + * The amount of memory allocated to your process. By default, this is capped + * at 8192 MB, but can be increased further on the Enterprise tier. */ @JsonIgnore public double requestedMemoryMB() { @@ -436,7 +438,8 @@ public Deployment withRequestedCPU(double requestedCPU) { } /** - * The amount of memory allocated to your process. + * The amount of memory allocated to your process. By default, this is capped + * at 8192 MB, but can be increased further on the Enterprise tier. */ public Deployment withRequestedMemoryMB(double requestedMemoryMB) { Utils.checkNotNull(requestedMemoryMB, "requestedMemoryMB"); @@ -690,7 +693,8 @@ public Builder requestedCPU(double requestedCPU) { } /** - * The amount of memory allocated to your process. + * The amount of memory allocated to your process. By default, this is capped + * at 8192 MB, but can be increased further on the Enterprise tier. */ public Builder requestedMemoryMB(double requestedMemoryMB) { Utils.checkNotNull(requestedMemoryMB, "requestedMemoryMB"); diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/DeploymentV1TransportType.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/DeploymentV1TransportType.java index 47bd0489..cbf25519 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/DeploymentV1TransportType.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/DeploymentV1TransportType.java @@ -4,28 +4,187 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; import java.lang.Deprecated; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ /** * DeploymentV1TransportType * @deprecated enum: This will be removed in a future release, please migrate away from it as soon as possible. */ @Deprecated -public enum DeploymentV1TransportType { - TCP("tcp"), - UDP("udp"), - TLS("tls"); +@JsonDeserialize(using = DeploymentV1TransportType._Deserializer.class) +@JsonSerialize(using = DeploymentV1TransportType._Serializer.class) +public class DeploymentV1TransportType { + + public static final DeploymentV1TransportType TCP = new DeploymentV1TransportType("tcp"); + public static final DeploymentV1TransportType UDP = new DeploymentV1TransportType("udp"); + public static final DeploymentV1TransportType TLS = new DeploymentV1TransportType("tls"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private DeploymentV1TransportType(String value) { this.value = value; } - + + /** + * Returns a DeploymentV1TransportType with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as DeploymentV1TransportType + */ + public static DeploymentV1TransportType of(String value) { + synchronized (DeploymentV1TransportType.class) { + return values.computeIfAbsent(value, v -> new DeploymentV1TransportType(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeploymentV1TransportType other = (DeploymentV1TransportType) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "DeploymentV1TransportType [value=" + value + "]"; + } + + // return an array just like an enum + public static DeploymentV1TransportType[] values() { + synchronized (DeploymentV1TransportType.class) { + return values.values().toArray(new DeploymentV1TransportType[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("tcp", TCP); + map.put("udp", UDP); + map.put("tls", TLS); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("tcp", DeploymentV1TransportTypeEnum.TCP); + map.put("udp", DeploymentV1TransportTypeEnum.UDP); + map.put("tls", DeploymentV1TransportTypeEnum.TLS); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(DeploymentV1TransportType.class); + } + + @Override + public void serialize(DeploymentV1TransportType value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(DeploymentV1TransportType.class); + } + + @Override + public DeploymentV1TransportType deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return DeploymentV1TransportType.of(v); + } + } + + public enum DeploymentV1TransportTypeEnum { + + TCP("tcp"), + UDP("udp"), + TLS("tls"),; + + private final String value; + + private DeploymentV1TransportTypeEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/DeploymentV3.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/DeploymentV3.java index cd19a1a4..08d82b3a 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/DeploymentV3.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/DeploymentV3.java @@ -97,7 +97,8 @@ public class DeploymentV3 { private double requestedCPU; /** - * The amount of memory allocated to your process. + * The amount of memory allocated to your process. By default, this is capped + * at 8192 MB, but can be increased further on the Enterprise tier. */ @JsonProperty("requestedMemoryMB") private double requestedMemoryMB; @@ -265,7 +266,8 @@ public double requestedCPU() { } /** - * The amount of memory allocated to your process. + * The amount of memory allocated to your process. By default, this is capped + * at 8192 MB, but can be increased further on the Enterprise tier. */ @JsonIgnore public double requestedMemoryMB() { @@ -409,7 +411,8 @@ public DeploymentV3 withRequestedCPU(double requestedCPU) { } /** - * The amount of memory allocated to your process. + * The amount of memory allocated to your process. By default, this is capped + * at 8192 MB, but can be increased further on the Enterprise tier. */ public DeploymentV3 withRequestedMemoryMB(double requestedMemoryMB) { Utils.checkNotNull(requestedMemoryMB, "requestedMemoryMB"); @@ -649,7 +652,8 @@ public Builder requestedCPU(double requestedCPU) { } /** - * The amount of memory allocated to your process. + * The amount of memory allocated to your process. By default, this is capped + * at 8192 MB, but can be increased further on the Enterprise tier. */ public Builder requestedMemoryMB(double requestedMemoryMB) { Utils.checkNotNull(requestedMemoryMB, "requestedMemoryMB"); diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/DeprecatedProcessMetricName.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/DeprecatedProcessMetricName.java index 1f14eb78..5d3cb108 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/DeprecatedProcessMetricName.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/DeprecatedProcessMetricName.java @@ -4,24 +4,189 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = DeprecatedProcessMetricName._Deserializer.class) +@JsonSerialize(using = DeprecatedProcessMetricName._Serializer.class) +public class DeprecatedProcessMetricName { -public enum DeprecatedProcessMetricName { - CPU("cpu"), - MEMORY("memory"), - RATE_EGRESS("rate_egress"), - TOTAL_EGRESS("total_egress"), - ACTIVE_CONNECTIONS("active_connections"); + public static final DeprecatedProcessMetricName CPU = new DeprecatedProcessMetricName("cpu"); + public static final DeprecatedProcessMetricName MEMORY = new DeprecatedProcessMetricName("memory"); + public static final DeprecatedProcessMetricName RATE_EGRESS = new DeprecatedProcessMetricName("rate_egress"); + public static final DeprecatedProcessMetricName TOTAL_EGRESS = new DeprecatedProcessMetricName("total_egress"); + public static final DeprecatedProcessMetricName ACTIVE_CONNECTIONS = new DeprecatedProcessMetricName("active_connections"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private DeprecatedProcessMetricName(String value) { this.value = value; } - + + /** + * Returns a DeprecatedProcessMetricName with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as DeprecatedProcessMetricName + */ + public static DeprecatedProcessMetricName of(String value) { + synchronized (DeprecatedProcessMetricName.class) { + return values.computeIfAbsent(value, v -> new DeprecatedProcessMetricName(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeprecatedProcessMetricName other = (DeprecatedProcessMetricName) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "DeprecatedProcessMetricName [value=" + value + "]"; + } + + // return an array just like an enum + public static DeprecatedProcessMetricName[] values() { + synchronized (DeprecatedProcessMetricName.class) { + return values.values().toArray(new DeprecatedProcessMetricName[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("cpu", CPU); + map.put("memory", MEMORY); + map.put("rate_egress", RATE_EGRESS); + map.put("total_egress", TOTAL_EGRESS); + map.put("active_connections", ACTIVE_CONNECTIONS); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("cpu", DeprecatedProcessMetricNameEnum.CPU); + map.put("memory", DeprecatedProcessMetricNameEnum.MEMORY); + map.put("rate_egress", DeprecatedProcessMetricNameEnum.RATE_EGRESS); + map.put("total_egress", DeprecatedProcessMetricNameEnum.TOTAL_EGRESS); + map.put("active_connections", DeprecatedProcessMetricNameEnum.ACTIVE_CONNECTIONS); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(DeprecatedProcessMetricName.class); + } + + @Override + public void serialize(DeprecatedProcessMetricName value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(DeprecatedProcessMetricName.class); + } + + @Override + public DeprecatedProcessMetricName deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return DeprecatedProcessMetricName.of(v); + } + } + + public enum DeprecatedProcessMetricNameEnum { + + CPU("cpu"), + MEMORY("memory"), + RATE_EGRESS("rate_egress"), + TOTAL_EGRESS("total_egress"), + ACTIVE_CONNECTIONS("active_connections"),; + + private final String value; + + private DeprecatedProcessMetricNameEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/FleetMetricName.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/FleetMetricName.java index d829f7c9..09609760 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/FleetMetricName.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/FleetMetricName.java @@ -4,23 +4,185 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = FleetMetricName._Deserializer.class) +@JsonSerialize(using = FleetMetricName._Serializer.class) +public class FleetMetricName { -public enum FleetMetricName { - PROVISIONED_TOTAL("provisionedTotal"), - PROVISIONED_BARE_METAL("provisionedBareMetal"), - PROVISIONED_CLOUD("provisionedCloud"), - UTILIZED("utilized"); + public static final FleetMetricName PROVISIONED_TOTAL = new FleetMetricName("provisionedTotal"); + public static final FleetMetricName PROVISIONED_BARE_METAL = new FleetMetricName("provisionedBareMetal"); + public static final FleetMetricName PROVISIONED_CLOUD = new FleetMetricName("provisionedCloud"); + public static final FleetMetricName UTILIZED = new FleetMetricName("utilized"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private FleetMetricName(String value) { this.value = value; } - + + /** + * Returns a FleetMetricName with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as FleetMetricName + */ + public static FleetMetricName of(String value) { + synchronized (FleetMetricName.class) { + return values.computeIfAbsent(value, v -> new FleetMetricName(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + FleetMetricName other = (FleetMetricName) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "FleetMetricName [value=" + value + "]"; + } + + // return an array just like an enum + public static FleetMetricName[] values() { + synchronized (FleetMetricName.class) { + return values.values().toArray(new FleetMetricName[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("provisionedTotal", PROVISIONED_TOTAL); + map.put("provisionedBareMetal", PROVISIONED_BARE_METAL); + map.put("provisionedCloud", PROVISIONED_CLOUD); + map.put("utilized", UTILIZED); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("provisionedTotal", FleetMetricNameEnum.PROVISIONED_TOTAL); + map.put("provisionedBareMetal", FleetMetricNameEnum.PROVISIONED_BARE_METAL); + map.put("provisionedCloud", FleetMetricNameEnum.PROVISIONED_CLOUD); + map.put("utilized", FleetMetricNameEnum.UTILIZED); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(FleetMetricName.class); + } + + @Override + public void serialize(FleetMetricName value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(FleetMetricName.class); + } + + @Override + public FleetMetricName deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return FleetMetricName.of(v); + } + } + + public enum FleetMetricNameEnum { + + PROVISIONED_TOTAL("provisionedTotal"), + PROVISIONED_BARE_METAL("provisionedBareMetal"), + PROVISIONED_CLOUD("provisionedCloud"), + UTILIZED("utilized"),; + + private final String value; + + private FleetMetricNameEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/InvoiceStatus.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/InvoiceStatus.java index 8c6335bc..35e7279b 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/InvoiceStatus.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/InvoiceStatus.java @@ -4,22 +4,181 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = InvoiceStatus._Deserializer.class) +@JsonSerialize(using = InvoiceStatus._Serializer.class) +public class InvoiceStatus { -public enum InvoiceStatus { - PENDING("pending"), - PAID("paid"), - OVERDUE("overdue"); + public static final InvoiceStatus PENDING = new InvoiceStatus("pending"); + public static final InvoiceStatus PAID = new InvoiceStatus("paid"); + public static final InvoiceStatus OVERDUE = new InvoiceStatus("overdue"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private InvoiceStatus(String value) { this.value = value; } - + + /** + * Returns a InvoiceStatus with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as InvoiceStatus + */ + public static InvoiceStatus of(String value) { + synchronized (InvoiceStatus.class) { + return values.computeIfAbsent(value, v -> new InvoiceStatus(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InvoiceStatus other = (InvoiceStatus) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "InvoiceStatus [value=" + value + "]"; + } + + // return an array just like an enum + public static InvoiceStatus[] values() { + synchronized (InvoiceStatus.class) { + return values.values().toArray(new InvoiceStatus[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("pending", PENDING); + map.put("paid", PAID); + map.put("overdue", OVERDUE); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("pending", InvoiceStatusEnum.PENDING); + map.put("paid", InvoiceStatusEnum.PAID); + map.put("overdue", InvoiceStatusEnum.OVERDUE); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(InvoiceStatus.class); + } + + @Override + public void serialize(InvoiceStatus value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(InvoiceStatus.class); + } + + @Override + public InvoiceStatus deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return InvoiceStatus.of(v); + } + } + + public enum InvoiceStatusEnum { + + PENDING("pending"), + PAID("paid"), + OVERDUE("overdue"),; + + private final String value; + + private InvoiceStatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/LobbyVisibility.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/LobbyVisibility.java index d49f6cef..66bd5cbf 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/LobbyVisibility.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/LobbyVisibility.java @@ -4,9 +4,45 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ /** * LobbyVisibility - Types of lobbies a player can create. * @@ -16,19 +52,142 @@ * * `local`: for testing with a server running locally */ -public enum LobbyVisibility { - PRIVATE("private"), - PUBLIC("public"), - LOCAL("local"); +@JsonDeserialize(using = LobbyVisibility._Deserializer.class) +@JsonSerialize(using = LobbyVisibility._Serializer.class) +public class LobbyVisibility { + + public static final LobbyVisibility PRIVATE = new LobbyVisibility("private"); + public static final LobbyVisibility PUBLIC = new LobbyVisibility("public"); + public static final LobbyVisibility LOCAL = new LobbyVisibility("local"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private LobbyVisibility(String value) { this.value = value; } - + + /** + * Returns a LobbyVisibility with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as LobbyVisibility + */ + public static LobbyVisibility of(String value) { + synchronized (LobbyVisibility.class) { + return values.computeIfAbsent(value, v -> new LobbyVisibility(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LobbyVisibility other = (LobbyVisibility) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "LobbyVisibility [value=" + value + "]"; + } + + // return an array just like an enum + public static LobbyVisibility[] values() { + synchronized (LobbyVisibility.class) { + return values.values().toArray(new LobbyVisibility[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("private", PRIVATE); + map.put("public", PUBLIC); + map.put("local", LOCAL); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("private", LobbyVisibilityEnum.PRIVATE); + map.put("public", LobbyVisibilityEnum.PUBLIC); + map.put("local", LobbyVisibilityEnum.LOCAL); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(LobbyVisibility.class); + } + + @Override + public void serialize(LobbyVisibility value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(LobbyVisibility.class); + } + + @Override + public LobbyVisibility deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return LobbyVisibility.of(v); + } + } + + public enum LobbyVisibilityEnum { + + PRIVATE("private"), + PUBLIC("public"), + LOCAL("local"),; + + private final String value; + + private LobbyVisibilityEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/OrgToken2.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/OrgToken2.java index 6da757c5..c021c387 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/OrgToken2.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/OrgToken2.java @@ -4,20 +4,173 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = OrgToken2._Deserializer.class) +@JsonSerialize(using = OrgToken2._Serializer.class) +public class OrgToken2 { -public enum OrgToken2 { - ADMIN("admin"); + public static final OrgToken2 ADMIN = new OrgToken2("admin"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private OrgToken2(String value) { this.value = value; } - + + /** + * Returns a OrgToken2 with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as OrgToken2 + */ + public static OrgToken2 of(String value) { + synchronized (OrgToken2.class) { + return values.computeIfAbsent(value, v -> new OrgToken2(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + OrgToken2 other = (OrgToken2) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "OrgToken2 [value=" + value + "]"; + } + + // return an array just like an enum + public static OrgToken2[] values() { + synchronized (OrgToken2.class) { + return values.values().toArray(new OrgToken2[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("admin", ADMIN); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("admin", OrgToken2Enum.ADMIN); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(OrgToken2.class); + } + + @Override + public void serialize(OrgToken2 value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(OrgToken2.class); + } + + @Override + public OrgToken2 deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return OrgToken2.of(v); + } + } + + public enum OrgToken2Enum { + + ADMIN("admin"),; + + private final String value; + + private OrgToken2Enum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/OrgTokenStatus.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/OrgTokenStatus.java index ae89791f..507657ec 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/OrgTokenStatus.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/OrgTokenStatus.java @@ -4,21 +4,177 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = OrgTokenStatus._Deserializer.class) +@JsonSerialize(using = OrgTokenStatus._Serializer.class) +public class OrgTokenStatus { -public enum OrgTokenStatus { - ACTIVE("active"), - REVOKED("revoked"); + public static final OrgTokenStatus ACTIVE = new OrgTokenStatus("active"); + public static final OrgTokenStatus REVOKED = new OrgTokenStatus("revoked"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private OrgTokenStatus(String value) { this.value = value; } - + + /** + * Returns a OrgTokenStatus with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as OrgTokenStatus + */ + public static OrgTokenStatus of(String value) { + synchronized (OrgTokenStatus.class) { + return values.computeIfAbsent(value, v -> new OrgTokenStatus(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + OrgTokenStatus other = (OrgTokenStatus) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "OrgTokenStatus [value=" + value + "]"; + } + + // return an array just like an enum + public static OrgTokenStatus[] values() { + synchronized (OrgTokenStatus.class) { + return values.values().toArray(new OrgTokenStatus[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("active", ACTIVE); + map.put("revoked", REVOKED); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("active", OrgTokenStatusEnum.ACTIVE); + map.put("revoked", OrgTokenStatusEnum.REVOKED); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(OrgTokenStatus.class); + } + + @Override + public void serialize(OrgTokenStatus value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(OrgTokenStatus.class); + } + + @Override + public OrgTokenStatus deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return OrgTokenStatus.of(v); + } + } + + public enum OrgTokenStatusEnum { + + ACTIVE("active"), + REVOKED("revoked"),; + + private final String value; + + private OrgTokenStatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/PlanName.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/PlanName.java index be67f4f3..012ea312 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/PlanName.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/PlanName.java @@ -4,9 +4,45 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ /** * PlanName - A plan defines how much CPU and memory is required to run an instance of your game server. * @@ -18,20 +54,146 @@ * * `large`: 4 core, 8gb memory */ -public enum PlanName { - TINY("tiny"), - SMALL("small"), - MEDIUM("medium"), - LARGE("large"); +@JsonDeserialize(using = PlanName._Deserializer.class) +@JsonSerialize(using = PlanName._Serializer.class) +public class PlanName { + + public static final PlanName TINY = new PlanName("tiny"); + public static final PlanName SMALL = new PlanName("small"); + public static final PlanName MEDIUM = new PlanName("medium"); + public static final PlanName LARGE = new PlanName("large"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private PlanName(String value) { this.value = value; } - + + /** + * Returns a PlanName with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as PlanName + */ + public static PlanName of(String value) { + synchronized (PlanName.class) { + return values.computeIfAbsent(value, v -> new PlanName(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PlanName other = (PlanName) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "PlanName [value=" + value + "]"; + } + + // return an array just like an enum + public static PlanName[] values() { + synchronized (PlanName.class) { + return values.values().toArray(new PlanName[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("tiny", TINY); + map.put("small", SMALL); + map.put("medium", MEDIUM); + map.put("large", LARGE); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("tiny", PlanNameEnum.TINY); + map.put("small", PlanNameEnum.SMALL); + map.put("medium", PlanNameEnum.MEDIUM); + map.put("large", PlanNameEnum.LARGE); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(PlanName.class); + } + + @Override + public void serialize(PlanName value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(PlanName.class); + } + + @Override + public PlanName deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return PlanName.of(v); + } + } + + public enum PlanNameEnum { + + TINY("tiny"), + SMALL("small"), + MEDIUM("medium"), + LARGE("large"),; + + private final String value; + + private PlanNameEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/ProcessMetricName.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/ProcessMetricName.java index 13b1b9db..5723bfaf 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/ProcessMetricName.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/ProcessMetricName.java @@ -4,27 +4,192 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ /** * ProcessMetricName - Available metrics to query over time. */ -public enum ProcessMetricName { - CPU("cpu"), - MEMORY("memory"), - RATE_EGRESS("rateEgress"), - TOTAL_EGRESS("totalEgress"), - ACTIVE_CONNECTIONS("activeConnections"); - - @JsonValue +@JsonDeserialize(using = ProcessMetricName._Deserializer.class) +@JsonSerialize(using = ProcessMetricName._Serializer.class) +public class ProcessMetricName { + + public static final ProcessMetricName CPU = new ProcessMetricName("cpu"); + public static final ProcessMetricName MEMORY = new ProcessMetricName("memory"); + public static final ProcessMetricName RATE_EGRESS = new ProcessMetricName("rateEgress"); + public static final ProcessMetricName TOTAL_EGRESS = new ProcessMetricName("totalEgress"); + public static final ProcessMetricName ACTIVE_CONNECTIONS = new ProcessMetricName("activeConnections"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); + private final String value; private ProcessMetricName(String value) { this.value = value; } - + + /** + * Returns a ProcessMetricName with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as ProcessMetricName + */ + public static ProcessMetricName of(String value) { + synchronized (ProcessMetricName.class) { + return values.computeIfAbsent(value, v -> new ProcessMetricName(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ProcessMetricName other = (ProcessMetricName) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "ProcessMetricName [value=" + value + "]"; + } + + // return an array just like an enum + public static ProcessMetricName[] values() { + synchronized (ProcessMetricName.class) { + return values.values().toArray(new ProcessMetricName[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("cpu", CPU); + map.put("memory", MEMORY); + map.put("rateEgress", RATE_EGRESS); + map.put("totalEgress", TOTAL_EGRESS); + map.put("activeConnections", ACTIVE_CONNECTIONS); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("cpu", ProcessMetricNameEnum.CPU); + map.put("memory", ProcessMetricNameEnum.MEMORY); + map.put("rateEgress", ProcessMetricNameEnum.RATE_EGRESS); + map.put("totalEgress", ProcessMetricNameEnum.TOTAL_EGRESS); + map.put("activeConnections", ProcessMetricNameEnum.ACTIVE_CONNECTIONS); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(ProcessMetricName.class); + } + + @Override + public void serialize(ProcessMetricName value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(ProcessMetricName.class); + } + + @Override + public ProcessMetricName deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return ProcessMetricName.of(v); + } + } + + public enum ProcessMetricNameEnum { + + CPU("cpu"), + MEMORY("memory"), + RATE_EGRESS("rateEgress"), + TOTAL_EGRESS("totalEgress"), + ACTIVE_CONNECTIONS("activeConnections"),; + + private final String value; + + private ProcessMetricNameEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/ProcessStatus.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/ProcessStatus.java index ef20442e..67f71e1e 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/ProcessStatus.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/ProcessStatus.java @@ -4,25 +4,193 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = ProcessStatus._Deserializer.class) +@JsonSerialize(using = ProcessStatus._Serializer.class) +public class ProcessStatus { -public enum ProcessStatus { - STARTING("starting"), - RUNNING("running"), - DRAINING("draining"), - STOPPING("stopping"), - STOPPED("stopped"), - FAILED("failed"); + public static final ProcessStatus STARTING = new ProcessStatus("starting"); + public static final ProcessStatus RUNNING = new ProcessStatus("running"); + public static final ProcessStatus DRAINING = new ProcessStatus("draining"); + public static final ProcessStatus STOPPING = new ProcessStatus("stopping"); + public static final ProcessStatus STOPPED = new ProcessStatus("stopped"); + public static final ProcessStatus FAILED = new ProcessStatus("failed"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private ProcessStatus(String value) { this.value = value; } - + + /** + * Returns a ProcessStatus with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as ProcessStatus + */ + public static ProcessStatus of(String value) { + synchronized (ProcessStatus.class) { + return values.computeIfAbsent(value, v -> new ProcessStatus(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ProcessStatus other = (ProcessStatus) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "ProcessStatus [value=" + value + "]"; + } + + // return an array just like an enum + public static ProcessStatus[] values() { + synchronized (ProcessStatus.class) { + return values.values().toArray(new ProcessStatus[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("starting", STARTING); + map.put("running", RUNNING); + map.put("draining", DRAINING); + map.put("stopping", STOPPING); + map.put("stopped", STOPPED); + map.put("failed", FAILED); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("starting", ProcessStatusEnum.STARTING); + map.put("running", ProcessStatusEnum.RUNNING); + map.put("draining", ProcessStatusEnum.DRAINING); + map.put("stopping", ProcessStatusEnum.STOPPING); + map.put("stopped", ProcessStatusEnum.STOPPED); + map.put("failed", ProcessStatusEnum.FAILED); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(ProcessStatus.class); + } + + @Override + public void serialize(ProcessStatus value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(ProcessStatus.class); + } + + @Override + public ProcessStatus deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return ProcessStatus.of(v); + } + } + + public enum ProcessStatusEnum { + + STARTING("starting"), + RUNNING("running"), + DRAINING("draining"), + STOPPING("stopping"), + STOPPED("stopped"), + FAILED("failed"),; + + private final String value; + + private ProcessStatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/Region.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/Region.java index 699e0762..b90c31d1 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/Region.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/Region.java @@ -4,33 +4,225 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = Region._Deserializer.class) +@JsonSerialize(using = Region._Serializer.class) +public class Region { + + public static final Region SEATTLE = new Region("Seattle"); + public static final Region LOS_ANGELES = new Region("Los_Angeles"); + public static final Region WASHINGTON_DC = new Region("Washington_DC"); + public static final Region CHICAGO = new Region("Chicago"); + public static final Region LONDON = new Region("London"); + public static final Region FRANKFURT = new Region("Frankfurt"); + public static final Region MUMBAI = new Region("Mumbai"); + public static final Region SINGAPORE = new Region("Singapore"); + public static final Region TOKYO = new Region("Tokyo"); + public static final Region SYDNEY = new Region("Sydney"); + public static final Region SAO_PAULO = new Region("Sao_Paulo"); + public static final Region DALLAS = new Region("Dallas"); + public static final Region JOHANNESBURG = new Region("Johannesburg"); + public static final Region DUBAI = new Region("Dubai"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); -public enum Region { - SEATTLE("Seattle"), - LOS_ANGELES("Los_Angeles"), - WASHINGTON_DC("Washington_DC"), - CHICAGO("Chicago"), - LONDON("London"), - FRANKFURT("Frankfurt"), - MUMBAI("Mumbai"), - SINGAPORE("Singapore"), - TOKYO("Tokyo"), - SYDNEY("Sydney"), - SAO_PAULO("Sao_Paulo"), - DALLAS("Dallas"), - JOHANNESBURG("Johannesburg"), - DUBAI("Dubai"); - - @JsonValue private final String value; private Region(String value) { this.value = value; } - + + /** + * Returns a Region with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as Region + */ + public static Region of(String value) { + synchronized (Region.class) { + return values.computeIfAbsent(value, v -> new Region(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Region other = (Region) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "Region [value=" + value + "]"; + } + + // return an array just like an enum + public static Region[] values() { + synchronized (Region.class) { + return values.values().toArray(new Region[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("Seattle", SEATTLE); + map.put("Los_Angeles", LOS_ANGELES); + map.put("Washington_DC", WASHINGTON_DC); + map.put("Chicago", CHICAGO); + map.put("London", LONDON); + map.put("Frankfurt", FRANKFURT); + map.put("Mumbai", MUMBAI); + map.put("Singapore", SINGAPORE); + map.put("Tokyo", TOKYO); + map.put("Sydney", SYDNEY); + map.put("Sao_Paulo", SAO_PAULO); + map.put("Dallas", DALLAS); + map.put("Johannesburg", JOHANNESBURG); + map.put("Dubai", DUBAI); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("Seattle", RegionEnum.SEATTLE); + map.put("Los_Angeles", RegionEnum.LOS_ANGELES); + map.put("Washington_DC", RegionEnum.WASHINGTON_DC); + map.put("Chicago", RegionEnum.CHICAGO); + map.put("London", RegionEnum.LONDON); + map.put("Frankfurt", RegionEnum.FRANKFURT); + map.put("Mumbai", RegionEnum.MUMBAI); + map.put("Singapore", RegionEnum.SINGAPORE); + map.put("Tokyo", RegionEnum.TOKYO); + map.put("Sydney", RegionEnum.SYDNEY); + map.put("Sao_Paulo", RegionEnum.SAO_PAULO); + map.put("Dallas", RegionEnum.DALLAS); + map.put("Johannesburg", RegionEnum.JOHANNESBURG); + map.put("Dubai", RegionEnum.DUBAI); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(Region.class); + } + + @Override + public void serialize(Region value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(Region.class); + } + + @Override + public Region deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return Region.of(v); + } + } + + public enum RegionEnum { + + SEATTLE("Seattle"), + LOS_ANGELES("Los_Angeles"), + WASHINGTON_DC("Washington_DC"), + CHICAGO("Chicago"), + LONDON("London"), + FRANKFURT("Frankfurt"), + MUMBAI("Mumbai"), + SINGAPORE("Singapore"), + TOKYO("Tokyo"), + SYDNEY("Sydney"), + SAO_PAULO("Sao_Paulo"), + DALLAS("Dallas"), + JOHANNESBURG("Johannesburg"), + DUBAI("Dubai"),; + + private final String value; + + private RegionEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/RoomReadyStatus.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/RoomReadyStatus.java index 34fb8dc8..0007c288 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/RoomReadyStatus.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/RoomReadyStatus.java @@ -4,21 +4,177 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = RoomReadyStatus._Deserializer.class) +@JsonSerialize(using = RoomReadyStatus._Serializer.class) +public class RoomReadyStatus { -public enum RoomReadyStatus { - ACTIVE("active"), - STARTING("starting"); + public static final RoomReadyStatus ACTIVE = new RoomReadyStatus("active"); + public static final RoomReadyStatus STARTING = new RoomReadyStatus("starting"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private RoomReadyStatus(String value) { this.value = value; } - + + /** + * Returns a RoomReadyStatus with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as RoomReadyStatus + */ + public static RoomReadyStatus of(String value) { + synchronized (RoomReadyStatus.class) { + return values.computeIfAbsent(value, v -> new RoomReadyStatus(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RoomReadyStatus other = (RoomReadyStatus) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "RoomReadyStatus [value=" + value + "]"; + } + + // return an array just like an enum + public static RoomReadyStatus[] values() { + synchronized (RoomReadyStatus.class) { + return values.values().toArray(new RoomReadyStatus[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("active", ACTIVE); + map.put("starting", STARTING); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("active", RoomReadyStatusEnum.ACTIVE); + map.put("starting", RoomReadyStatusEnum.STARTING); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(RoomReadyStatus.class); + } + + @Override + public void serialize(RoomReadyStatus value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(RoomReadyStatus.class); + } + + @Override + public RoomReadyStatus deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return RoomReadyStatus.of(v); + } + } + + public enum RoomReadyStatusEnum { + + ACTIVE("active"), + STARTING("starting"),; + + private final String value; + + private RoomReadyStatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/RoomStatus.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/RoomStatus.java index 7d18358c..111934a4 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/RoomStatus.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/RoomStatus.java @@ -4,9 +4,45 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ /** * RoomStatus - The allocation status of a room. * @@ -16,19 +52,142 @@ * * `destroyed`: all associated metadata is deleted */ -public enum RoomStatus { - SCHEDULING("scheduling"), - ACTIVE("active"), - DESTROYED("destroyed"); +@JsonDeserialize(using = RoomStatus._Deserializer.class) +@JsonSerialize(using = RoomStatus._Serializer.class) +public class RoomStatus { + + public static final RoomStatus SCHEDULING = new RoomStatus("scheduling"); + public static final RoomStatus ACTIVE = new RoomStatus("active"); + public static final RoomStatus DESTROYED = new RoomStatus("destroyed"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private RoomStatus(String value) { this.value = value; } - + + /** + * Returns a RoomStatus with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as RoomStatus + */ + public static RoomStatus of(String value) { + synchronized (RoomStatus.class) { + return values.computeIfAbsent(value, v -> new RoomStatus(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RoomStatus other = (RoomStatus) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "RoomStatus [value=" + value + "]"; + } + + // return an array just like an enum + public static RoomStatus[] values() { + synchronized (RoomStatus.class) { + return values.values().toArray(new RoomStatus[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("scheduling", SCHEDULING); + map.put("active", ACTIVE); + map.put("destroyed", DESTROYED); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("scheduling", RoomStatusEnum.SCHEDULING); + map.put("active", RoomStatusEnum.ACTIVE); + map.put("destroyed", RoomStatusEnum.DESTROYED); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(RoomStatus.class); + } + + @Override + public void serialize(RoomStatus value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(RoomStatus.class); + } + + @Override + public RoomStatus deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return RoomStatus.of(v); + } + } + + public enum RoomStatusEnum { + + SCHEDULING("scheduling"), + ACTIVE("active"), + DESTROYED("destroyed"),; + + private final String value; + + private RoomStatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/Scope.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/Scope.java index 02ca0a43..9e6687b1 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/Scope.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/Scope.java @@ -4,34 +4,229 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = Scope._Deserializer.class) +@JsonSerialize(using = Scope._Serializer.class) +public class Scope { + + public static final Scope BILLING_READ_WRITE = new Scope("billing:read-write"); + public static final Scope BUILDS_READ = new Scope("builds:read"); + public static final Scope BUILDS_READ_WRITE = new Scope("builds:read-write"); + public static final Scope DEPLOYMENTS_READ = new Scope("deployments:read"); + public static final Scope DEPLOYMENTS_READ_WRITE = new Scope("deployments:read-write"); + public static final Scope APPLICATIONS_READ = new Scope("applications:read"); + public static final Scope APPLICATIONS_READ_WRITE = new Scope("applications:read-write"); + public static final Scope PROCESSES_READ = new Scope("processes:read"); + public static final Scope PROCESSES_READ_WRITE = new Scope("processes:read-write"); + public static final Scope FLEETS_READ = new Scope("fleets:read"); + public static final Scope FLEETS_READ_WRITE = new Scope("fleets:read-write"); + public static final Scope ORGS_READ = new Scope("orgs:read"); + public static final Scope ORGS_READ_WRITE = new Scope("orgs:read-write"); + public static final Scope TOKENS_READ = new Scope("tokens:read"); + public static final Scope TOKENS_READ_WRITE = new Scope("tokens:read-write"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); -public enum Scope { - BILLING_READ_WRITE("billing:read-write"), - BUILDS_READ("builds:read"), - BUILDS_READ_WRITE("builds:read-write"), - DEPLOYMENTS_READ("deployments:read"), - DEPLOYMENTS_READ_WRITE("deployments:read-write"), - APPLICATIONS_READ("applications:read"), - APPLICATIONS_READ_WRITE("applications:read-write"), - PROCESSES_READ("processes:read"), - PROCESSES_READ_WRITE("processes:read-write"), - FLEETS_READ("fleets:read"), - FLEETS_READ_WRITE("fleets:read-write"), - ORGS_READ("orgs:read"), - ORGS_READ_WRITE("orgs:read-write"), - TOKENS_READ("tokens:read"), - TOKENS_READ_WRITE("tokens:read-write"); - - @JsonValue private final String value; private Scope(String value) { this.value = value; } - + + /** + * Returns a Scope with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as Scope + */ + public static Scope of(String value) { + synchronized (Scope.class) { + return values.computeIfAbsent(value, v -> new Scope(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Scope other = (Scope) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "Scope [value=" + value + "]"; + } + + // return an array just like an enum + public static Scope[] values() { + synchronized (Scope.class) { + return values.values().toArray(new Scope[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("billing:read-write", BILLING_READ_WRITE); + map.put("builds:read", BUILDS_READ); + map.put("builds:read-write", BUILDS_READ_WRITE); + map.put("deployments:read", DEPLOYMENTS_READ); + map.put("deployments:read-write", DEPLOYMENTS_READ_WRITE); + map.put("applications:read", APPLICATIONS_READ); + map.put("applications:read-write", APPLICATIONS_READ_WRITE); + map.put("processes:read", PROCESSES_READ); + map.put("processes:read-write", PROCESSES_READ_WRITE); + map.put("fleets:read", FLEETS_READ); + map.put("fleets:read-write", FLEETS_READ_WRITE); + map.put("orgs:read", ORGS_READ); + map.put("orgs:read-write", ORGS_READ_WRITE); + map.put("tokens:read", TOKENS_READ); + map.put("tokens:read-write", TOKENS_READ_WRITE); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("billing:read-write", ScopeEnum.BILLING_READ_WRITE); + map.put("builds:read", ScopeEnum.BUILDS_READ); + map.put("builds:read-write", ScopeEnum.BUILDS_READ_WRITE); + map.put("deployments:read", ScopeEnum.DEPLOYMENTS_READ); + map.put("deployments:read-write", ScopeEnum.DEPLOYMENTS_READ_WRITE); + map.put("applications:read", ScopeEnum.APPLICATIONS_READ); + map.put("applications:read-write", ScopeEnum.APPLICATIONS_READ_WRITE); + map.put("processes:read", ScopeEnum.PROCESSES_READ); + map.put("processes:read-write", ScopeEnum.PROCESSES_READ_WRITE); + map.put("fleets:read", ScopeEnum.FLEETS_READ); + map.put("fleets:read-write", ScopeEnum.FLEETS_READ_WRITE); + map.put("orgs:read", ScopeEnum.ORGS_READ); + map.put("orgs:read-write", ScopeEnum.ORGS_READ_WRITE); + map.put("tokens:read", ScopeEnum.TOKENS_READ); + map.put("tokens:read-write", ScopeEnum.TOKENS_READ_WRITE); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(Scope.class); + } + + @Override + public void serialize(Scope value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(Scope.class); + } + + @Override + public Scope deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return Scope.of(v); + } + } + + public enum ScopeEnum { + + BILLING_READ_WRITE("billing:read-write"), + BUILDS_READ("builds:read"), + BUILDS_READ_WRITE("builds:read-write"), + DEPLOYMENTS_READ("deployments:read"), + DEPLOYMENTS_READ_WRITE("deployments:read-write"), + APPLICATIONS_READ("applications:read"), + APPLICATIONS_READ_WRITE("applications:read-write"), + PROCESSES_READ("processes:read"), + PROCESSES_READ_WRITE("processes:read-write"), + FLEETS_READ("fleets:read"), + FLEETS_READ_WRITE("fleets:read-write"), + ORGS_READ("orgs:read"), + ORGS_READ_WRITE("orgs:read-write"), + TOKENS_READ("tokens:read"), + TOKENS_READ_WRITE("tokens:read-write"),; + + private final String value; + + private ScopeEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/StartingConnectionInfoStatus.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/StartingConnectionInfoStatus.java index 57552024..c8e1715c 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/StartingConnectionInfoStatus.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/StartingConnectionInfoStatus.java @@ -4,20 +4,173 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = StartingConnectionInfoStatus._Deserializer.class) +@JsonSerialize(using = StartingConnectionInfoStatus._Serializer.class) +public class StartingConnectionInfoStatus { -public enum StartingConnectionInfoStatus { - STARTING("starting"); + public static final StartingConnectionInfoStatus STARTING = new StartingConnectionInfoStatus("starting"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private StartingConnectionInfoStatus(String value) { this.value = value; } - + + /** + * Returns a StartingConnectionInfoStatus with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as StartingConnectionInfoStatus + */ + public static StartingConnectionInfoStatus of(String value) { + synchronized (StartingConnectionInfoStatus.class) { + return values.computeIfAbsent(value, v -> new StartingConnectionInfoStatus(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + StartingConnectionInfoStatus other = (StartingConnectionInfoStatus) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "StartingConnectionInfoStatus [value=" + value + "]"; + } + + // return an array just like an enum + public static StartingConnectionInfoStatus[] values() { + synchronized (StartingConnectionInfoStatus.class) { + return values.values().toArray(new StartingConnectionInfoStatus[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("starting", STARTING); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("starting", StartingConnectionInfoStatusEnum.STARTING); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(StartingConnectionInfoStatus.class); + } + + @Override + public void serialize(StartingConnectionInfoStatus value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(StartingConnectionInfoStatus.class); + } + + @Override + public StartingConnectionInfoStatus deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return StartingConnectionInfoStatus.of(v); + } + } + + public enum StartingConnectionInfoStatusEnum { + + STARTING("starting"),; + + private final String value; + + private StartingConnectionInfoStatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/Status.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/Status.java index 14d8d36c..2e11bfa5 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/Status.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/Status.java @@ -4,20 +4,173 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = Status._Deserializer.class) +@JsonSerialize(using = Status._Serializer.class) +public class Status { -public enum Status { - ACTIVE("active"); + public static final Status ACTIVE = new Status("active"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private Status(String value) { this.value = value; } - + + /** + * Returns a Status with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as Status + */ + public static Status of(String value) { + synchronized (Status.class) { + return values.computeIfAbsent(value, v -> new Status(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Status other = (Status) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "Status [value=" + value + "]"; + } + + // return an array just like an enum + public static Status[] values() { + synchronized (Status.class) { + return values.values().toArray(new Status[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("active", ACTIVE); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("active", StatusEnum.ACTIVE); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(Status.class); + } + + @Override + public void serialize(Status value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(Status.class); + } + + @Override + public Status deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return Status.of(v); + } + } + + public enum StatusEnum { + + ACTIVE("active"),; + + private final String value; + + private StatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/TransportType.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/TransportType.java index dcee5320..f8697410 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/TransportType.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/TransportType.java @@ -4,25 +4,184 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ /** * TransportType - Transport type specifies the underlying communication protocol to the exposed port. */ -public enum TransportType { - TCP("tcp"), - UDP("udp"), - TLS("tls"); +@JsonDeserialize(using = TransportType._Deserializer.class) +@JsonSerialize(using = TransportType._Serializer.class) +public class TransportType { + + public static final TransportType TCP = new TransportType("tcp"); + public static final TransportType UDP = new TransportType("udp"); + public static final TransportType TLS = new TransportType("tls"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private TransportType(String value) { this.value = value; } - + + /** + * Returns a TransportType with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as TransportType + */ + public static TransportType of(String value) { + synchronized (TransportType.class) { + return values.computeIfAbsent(value, v -> new TransportType(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TransportType other = (TransportType) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "TransportType [value=" + value + "]"; + } + + // return an array just like an enum + public static TransportType[] values() { + synchronized (TransportType.class) { + return values.values().toArray(new TransportType[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("tcp", TCP); + map.put("udp", UDP); + map.put("tls", TLS); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("tcp", TransportTypeEnum.TCP); + map.put("udp", TransportTypeEnum.UDP); + map.put("tls", TransportTypeEnum.TLS); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(TransportType.class); + } + + @Override + public void serialize(TransportType value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(TransportType.class); + } + + @Override + public TransportType deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return TransportType.of(v); + } + } + + public enum TransportTypeEnum { + + TCP("tcp"), + UDP("udp"), + TLS("tls"),; + + private final String value; + + private TransportTypeEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/Two.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/Two.java index 6cfcc2f4..f7af6580 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/Two.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/Two.java @@ -4,20 +4,173 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = Two._Deserializer.class) +@JsonSerialize(using = Two._Serializer.class) +public class Two { -public enum Two { - ADMIN("admin"); + public static final Two ADMIN = new Two("admin"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private Two(String value) { this.value = value; } - + + /** + * Returns a Two with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as Two + */ + public static Two of(String value) { + synchronized (Two.class) { + return values.computeIfAbsent(value, v -> new Two(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Two other = (Two) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "Two [value=" + value + "]"; + } + + // return an array just like an enum + public static Two[] values() { + synchronized (Two.class) { + return values.values().toArray(new Two[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("admin", ADMIN); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("admin", TwoEnum.ADMIN); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(Two.class); + } + + @Override + public void serialize(Two value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(Two.class); + } + + @Override + public Two deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return Two.of(v); + } + } + + public enum TwoEnum { + + ADMIN("admin"),; + + private final String value; + + private TwoEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/UserRole.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/UserRole.java index a3fffd20..17db9902 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/UserRole.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/UserRole.java @@ -4,22 +4,181 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = UserRole._Deserializer.class) +@JsonSerialize(using = UserRole._Serializer.class) +public class UserRole { -public enum UserRole { - ADMIN("admin"), - MEMBER("member"), - VIEWER("viewer"); + public static final UserRole ADMIN = new UserRole("admin"); + public static final UserRole MEMBER = new UserRole("member"); + public static final UserRole VIEWER = new UserRole("viewer"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private UserRole(String value) { this.value = value; } - + + /** + * Returns a UserRole with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as UserRole + */ + public static UserRole of(String value) { + synchronized (UserRole.class) { + return values.computeIfAbsent(value, v -> new UserRole(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UserRole other = (UserRole) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "UserRole [value=" + value + "]"; + } + + // return an array just like an enum + public static UserRole[] values() { + synchronized (UserRole.class) { + return values.values().toArray(new UserRole[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("admin", ADMIN); + map.put("member", MEMBER); + map.put("viewer", VIEWER); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("admin", UserRoleEnum.ADMIN); + map.put("member", UserRoleEnum.MEMBER); + map.put("viewer", UserRoleEnum.VIEWER); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(UserRole.class); + } + + @Override + public void serialize(UserRole value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(UserRole.class); + } + + @Override + public UserRole deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return UserRole.of(v); + } + } + + public enum UserRoleEnum { + + ADMIN("admin"), + MEMBER("member"), + VIEWER("viewer"),; + + private final String value; + + private UserRoleEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/models/shared/VerificationEmailSuccess.java b/src/main/java/dev/hathora/cloud_sdk/models/shared/VerificationEmailSuccess.java index 97d44b32..6f225dc2 100644 --- a/src/main/java/dev/hathora/cloud_sdk/models/shared/VerificationEmailSuccess.java +++ b/src/main/java/dev/hathora/cloud_sdk/models/shared/VerificationEmailSuccess.java @@ -4,20 +4,173 @@ package dev.hathora.cloud_sdk.models.shared; -import com.fasterxml.jackson.annotation.JsonValue; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.lang.Override; import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + *

Wrapper class for an "open" enum. "Open" enums are those that are expected + * to evolve (particularly with the addition of enum members over time). If an + * open enum is used then the appearance of unexpected enum values (say in a + * response from an updated an API) will not bring about a runtime error thus + * ensuring that non-updated client versions can continue to work without error. + * + *

Note that instances are immutable and are singletons (an internal thread-safe + * cache is maintained to ensure that). As a consequence instances created with the + * same value will satisfy reference equality (via {@code ==}). + * + *

This class is intended to emulate an enum (in terms of common usage and with + * reference equality) but with the ability to carry unknown values. Unfortunately + * Java does not permit the use of an instance in a switch expression but you can + * use the {@code asEnum()} method (after dealing with the `Optional` appropriately). + * + */ +@JsonDeserialize(using = VerificationEmailSuccess._Deserializer.class) +@JsonSerialize(using = VerificationEmailSuccess._Serializer.class) +public class VerificationEmailSuccess { -public enum VerificationEmailSuccess { - SUCCESS("success"); + public static final VerificationEmailSuccess SUCCESS = new VerificationEmailSuccess("success"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); - @JsonValue private final String value; private VerificationEmailSuccess(String value) { this.value = value; } - + + /** + * Returns a VerificationEmailSuccess with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as VerificationEmailSuccess + */ + public static VerificationEmailSuccess of(String value) { + synchronized (VerificationEmailSuccess.class) { + return values.computeIfAbsent(value, v -> new VerificationEmailSuccess(v)); + } + } + public String value() { return value; } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VerificationEmailSuccess other = (VerificationEmailSuccess) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "VerificationEmailSuccess [value=" + value + "]"; + } + + // return an array just like an enum + public static VerificationEmailSuccess[] values() { + synchronized (VerificationEmailSuccess.class) { + return values.values().toArray(new VerificationEmailSuccess[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("success", SUCCESS); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("success", VerificationEmailSuccessEnum.SUCCESS); + return map; + } + + @SuppressWarnings("serial") + public static final class _Serializer extends StdSerializer { + + protected _Serializer() { + super(VerificationEmailSuccess.class); + } + + @Override + public void serialize(VerificationEmailSuccess value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeObject(value.value); + } + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends StdDeserializer { + + protected _Deserializer() { + super(VerificationEmailSuccess.class); + } + + @Override + public VerificationEmailSuccess deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String v = p.readValueAs(new TypeReference() {}); + // use the factory method to ensure we get singletons + return VerificationEmailSuccess.of(v); + } + } + + public enum VerificationEmailSuccessEnum { + + SUCCESS("success"),; + + private final String value; + + private VerificationEmailSuccessEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } } diff --git a/src/main/java/dev/hathora/cloud_sdk/utils/BigDecimalString.java b/src/main/java/dev/hathora/cloud_sdk/utils/BigDecimalString.java index 72945190..d42eec37 100644 --- a/src/main/java/dev/hathora/cloud_sdk/utils/BigDecimalString.java +++ b/src/main/java/dev/hathora/cloud_sdk/utils/BigDecimalString.java @@ -24,8 +24,8 @@ // Note that Jackson 2.16.1 does not support @JsonValue and @JsonFormat combined so we must use // a custom serializer/deserializer -@JsonSerialize(using = BigDecimalString.BigDecimalStringSerializer.class) -@JsonDeserialize(using = BigDecimalString.BigDecimalStringDeserializer.class) +@JsonSerialize(using = BigDecimalString.Serializer.class) +@JsonDeserialize(using = BigDecimalString.Deserializer.class) public class BigDecimalString { private final BigDecimal value; @@ -64,16 +64,11 @@ public boolean equals(Object obj) { return Objects.equals(value, other.value); } - public static final class BigDecimalStringSerializer extends StdSerializer { + @SuppressWarnings("serial") + public static final class Serializer extends StdSerializer { - private static final long serialVersionUID = -3828937716095008071L; - - public BigDecimalStringSerializer() { - this(null); - } - - public BigDecimalStringSerializer(Class t) { - super(t); + protected Serializer() { + super(BigDecimalString.class); } @Override @@ -83,16 +78,11 @@ public void serialize(BigDecimalString value, JsonGenerator g, SerializerProvide } } - public static final class BigDecimalStringDeserializer extends StdDeserializer { - - private static final long serialVersionUID = -2474225842945673085L; - - public BigDecimalStringDeserializer() { - this(null); - } + @SuppressWarnings("serial") + public static final class Deserializer extends StdDeserializer { - public BigDecimalStringDeserializer(Class t) { - super(t); + protected Deserializer() { + super(BigDecimalString.class); } @Override diff --git a/src/main/java/dev/hathora/cloud_sdk/utils/BigIntegerString.java b/src/main/java/dev/hathora/cloud_sdk/utils/BigIntegerString.java index 60dc5df1..80add25e 100644 --- a/src/main/java/dev/hathora/cloud_sdk/utils/BigIntegerString.java +++ b/src/main/java/dev/hathora/cloud_sdk/utils/BigIntegerString.java @@ -24,8 +24,8 @@ // Note that Jackson 2.16.1 does not support @JsonValue and @JsonFormat combined so we must use // a custom serializer/deserializer -@JsonSerialize(using = BigIntegerString.BigIntegerStringSerializer.class) -@JsonDeserialize(using = BigIntegerString.BigIntegerStringDeserializer.class) +@JsonSerialize(using = BigIntegerString.Serializer.class) +@JsonDeserialize(using = BigIntegerString.Deserializer.class) public class BigIntegerString { private final BigInteger value; @@ -64,16 +64,11 @@ public boolean equals(Object obj) { return Objects.equals(value, other.value); } - public static final class BigIntegerStringSerializer extends StdSerializer { + @SuppressWarnings("serial") + public static final class Serializer extends StdSerializer { - private static final long serialVersionUID = -2474225842945673085L; - - public BigIntegerStringSerializer() { - this(null); - } - - public BigIntegerStringSerializer(Class t) { - super(t); + protected Serializer() { + super(BigIntegerString.class); } @Override @@ -83,16 +78,11 @@ public void serialize(BigIntegerString value, JsonGenerator g, SerializerProvide } } - public static final class BigIntegerStringDeserializer extends StdDeserializer { - - private static final long serialVersionUID = -2474225842945673085L; - - public BigIntegerStringDeserializer() { - this(null); - } + @SuppressWarnings("serial") + public static final class Deserializer extends StdDeserializer { - public BigIntegerStringDeserializer(Class t) { - super(t); + protected Deserializer() { + super(BigIntegerString.class); } @Override diff --git a/src/main/java/dev/hathora/cloud_sdk/utils/RequestBody.java b/src/main/java/dev/hathora/cloud_sdk/utils/RequestBody.java index 9cdb1db3..109ae6ed 100644 --- a/src/main/java/dev/hathora/cloud_sdk/utils/RequestBody.java +++ b/src/main/java/dev/hathora/cloud_sdk/utils/RequestBody.java @@ -12,17 +12,16 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.regex.Pattern; import java.util.Optional; +import java.util.regex.Pattern; -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.mime.HttpMultipartMode; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.message.BasicNameValuePair; - +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.client5.http.entity.mime.HttpMultipartMode; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.message.BasicNameValuePair; import org.openapitools.jackson.nullable.JsonNullable; import com.fasterxml.jackson.databind.ObjectMapper; @@ -120,7 +119,7 @@ private static SerializedBody serializeContentType(String fieldName, String cont private static SerializedBody serializeMultipart(Object value) throws IllegalArgumentException, IllegalAccessException, UnsupportedOperationException, IOException { MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.setMode(HttpMultipartMode.EXTENDED); String boundary = "-------------" + System.currentTimeMillis(); builder.setBoundary(boundary); @@ -143,7 +142,7 @@ private static SerializedBody serializeMultipart(Object value) } if (metadata.file) { - serializeMultipartFile(builder, val); + serializeMultipartFile(metadata.name, builder, val); } else if (metadata.json) { ObjectMapper mapper = JSON.getMapper(); String json = mapper.writeValueAsString(val); @@ -161,7 +160,7 @@ private static SerializedBody serializeMultipart(Object value) } HttpEntity entity = builder.build(); - String ct = builder.build().getContentType().getValue(); + String ct = builder.build().getContentType(); return new SerializedBody(ct, BodyPublishers.ofInputStream(() -> { try { return entity.getContent(); @@ -171,13 +170,12 @@ private static SerializedBody serializeMultipart(Object value) })); } - private static void serializeMultipartFile(MultipartEntityBuilder builder, Object file) + private static void serializeMultipartFile(String fieldName, MultipartEntityBuilder builder, Object file) throws IllegalArgumentException, IllegalAccessException { if (Types.getType(file.getClass()) != Types.OBJECT) { throw new RuntimeException("Invalid type for multipart file"); } - String fieldName = ""; String fileName = ""; byte[] content = null; @@ -199,12 +197,11 @@ private static void serializeMultipartFile(MultipartEntityBuilder builder, Objec if (metadata.content) { content = (byte[]) val; } else { - fieldName = metadata.name; fileName = Utils.valToString(val); } } - if (fieldName.isBlank() || fileName.isBlank() || content == null) { + if (fileName.isBlank() || content == null) { throw new RuntimeException("Invalid multipart file"); } @@ -336,8 +333,9 @@ public static SerializedBody serializeFormData(Object value) throw new RuntimeException("Invalid type for form data"); } + @SuppressWarnings("resource") UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params); - String ct = entity.getContentType().getValue(); + String ct = entity.getContentType(); // ensure that a fresh open input stream is provided every time // by the BodyPublisher return new SerializedBody(ct, BodyPublishers.ofInputStream(() -> {