diff --git a/api.md b/api.md index 0074768..9fb7160 100644 --- a/api.md +++ b/api.md @@ -14,7 +14,7 @@ item from that page on, and `pages()` every page, fetching the next ones on dema the response body as received. The async client's pages have `nextPage()`, `forEach(...)`, `forEachPage(...)` and `toList()`, returning `CompletableFuture`s. -[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Budgets](#budgets) · [Checkout sessions](#checkout-sessions) · [Checks](#checks) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Credit units](#credit-units) · [Credit units prices](#credit-units-prices) · [Credits](#credits) · [Credits grants](#credits-grants) · [Credits wallets](#credits-wallets) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Usage customer](#usage-customer) · [Usage costs](#usage-costs) · [Usage costs customer](#usage-costs-customer) · [Usage costs subscription](#usage-costs-subscription) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints) +[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Budgets](#budgets) · [Checkout sessions](#checkout-sessions) · [Checks](#checks) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Credit units](#credit-units) · [Credit units prices](#credit-units-prices) · [Credits](#credits) · [Credits grants](#credits-grants) · [Credits wallets](#credits-wallets) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Licenses](#licenses) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Usage customer](#usage-customer) · [Usage costs](#usage-costs) · [Usage costs customer](#usage-costs-customer) · [Usage costs subscription](#usage-costs-subscription) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints) ## Add ons @@ -238,6 +238,20 @@ the response body as received. The async client's pages have `nextPage()`, `forE | `Invoice client.invoices().refresh(String invoiceId)` | `POST /api/v1/invoices/{invoice_id}/refresh` | [`Invoice`](src/main/java/com/meteroid/models/Invoice.java) | | `byte[] client.invoices().downloadXml(String invoiceId)` | `GET /api/v1/invoices/{invoice_id}/xml` | bytes | +## Licenses + +[`client.licenses()`](src/main/java/com/meteroid/api/Licenses.java) + +| Method | Request | Returns | +| --- | --- | --- | +| `LicenseListResponse client.licenses().list([LicensesListOptions options])` | `GET /api/v1/licenses` | [`LicenseListResponse`](src/main/java/com/meteroid/models/LicenseListResponse.java) | +| `IssueLicenseResponse client.licenses().create(IssueLicenseRequest issueLicenseRequest)` | `POST /api/v1/licenses` | [`IssueLicenseResponse`](src/main/java/com/meteroid/models/IssueLicenseResponse.java) | +| `License client.licenses().retrieve(String licenseId)` | `GET /api/v1/licenses/{license_id}` | [`License`](src/main/java/com/meteroid/models/License.java) | +| `LicenseActivationCode client.licenses().retrieveActivationCode(String licenseId)` | `GET /api/v1/licenses/{license_id}/activation-code` | [`LicenseActivationCode`](src/main/java/com/meteroid/models/LicenseActivationCode.java) | +| `OfflineLicense client.licenses().offline(String licenseId, IssueOfflineLicenseRequest issueOfflineLicenseRequest)` | `POST /api/v1/licenses/{license_id}/offline` | [`OfflineLicense`](src/main/java/com/meteroid/models/OfflineLicense.java) | +| `License client.licenses().revoke(String licenseId, RevokeLicenseRequest revokeLicenseRequest)` | `POST /api/v1/licenses/{license_id}/revoke` | [`License`](src/main/java/com/meteroid/models/License.java) | +| `LicenseSigningKeysResponse client.licenses().listLicensingSigningKeys()` | `GET /api/v1/licensing/signing-keys` | [`LicenseSigningKeysResponse`](src/main/java/com/meteroid/models/LicenseSigningKeysResponse.java) | + ## Metrics [`client.metrics()`](src/main/java/com/meteroid/api/Metrics.java) diff --git a/src/main/java/com/meteroid/Meteroid.java b/src/main/java/com/meteroid/Meteroid.java index 255a7f4..ee2a721 100644 --- a/src/main/java/com/meteroid/Meteroid.java +++ b/src/main/java/com/meteroid/Meteroid.java @@ -17,6 +17,7 @@ import com.meteroid.api.Events; import com.meteroid.api.Features; import com.meteroid.api.Invoices; +import com.meteroid.api.Licenses; import com.meteroid.api.Metrics; import com.meteroid.api.Oauth; import com.meteroid.api.OauthApps; @@ -77,6 +78,7 @@ public final class Meteroid implements AutoCloseable { private final Events events; private final Features features; private final Invoices invoices; + private final Licenses licenses; private final Metrics metrics; private final Oauth oauth; private final OauthApps oauthApps; @@ -155,6 +157,7 @@ public Meteroid(MeteroidOptions options) { this.events = new Events(httpClient); this.features = new Features(httpClient); this.invoices = new Invoices(httpClient); + this.licenses = new Licenses(httpClient); this.metrics = new Metrics(httpClient); this.oauth = new Oauth(httpClient); this.oauthApps = new OauthApps(httpClient); @@ -354,6 +357,15 @@ public Invoices invoices() { return invoices; } + /** + * The {@code licenses} operations. + * + * @return the operations + */ + public Licenses licenses() { + return licenses; + } + /** * The {@code metrics} operations. * @@ -592,6 +604,15 @@ public Invoices.WithRawResponse invoices() { return invoices.withRawResponse(); } + /** + * The {@code licenses} operations. + * + * @return the operations + */ + public Licenses.WithRawResponse licenses() { + return licenses.withRawResponse(); + } + /** * The {@code metrics} operations. * diff --git a/src/main/java/com/meteroid/MeteroidAsync.java b/src/main/java/com/meteroid/MeteroidAsync.java index 6d22b7d..d9daf70 100644 --- a/src/main/java/com/meteroid/MeteroidAsync.java +++ b/src/main/java/com/meteroid/MeteroidAsync.java @@ -17,6 +17,7 @@ import com.meteroid.api.EventsAsync; import com.meteroid.api.FeaturesAsync; import com.meteroid.api.InvoicesAsync; +import com.meteroid.api.LicensesAsync; import com.meteroid.api.MetricsAsync; import com.meteroid.api.OauthAppsAsync; import com.meteroid.api.OauthAsync; @@ -52,6 +53,7 @@ public final class MeteroidAsync implements AutoCloseable { private final EventsAsync events; private final FeaturesAsync features; private final InvoicesAsync invoices; + private final LicensesAsync licenses; private final MetricsAsync metrics; private final OauthAsync oauth; private final OauthAppsAsync oauthApps; @@ -81,6 +83,7 @@ public final class MeteroidAsync implements AutoCloseable { this.events = new EventsAsync(sync.events()); this.features = new FeaturesAsync(sync.features()); this.invoices = new InvoicesAsync(sync.invoices()); + this.licenses = new LicensesAsync(sync.licenses()); this.metrics = new MetricsAsync(sync.metrics()); this.oauth = new OauthAsync(sync.oauth()); this.oauthApps = new OauthAppsAsync(sync.oauthApps()); @@ -256,6 +259,15 @@ public InvoicesAsync invoices() { return invoices; } + /** + * The {@code licenses} operations. + * + * @return the operations + */ + public LicensesAsync licenses() { + return licenses; + } + /** * The {@code metrics} operations. * @@ -500,6 +512,15 @@ public InvoicesAsync.WithRawResponse invoices() { return invoices.withRawResponse(); } + /** + * The {@code licenses} operations. + * + * @return the operations + */ + public LicensesAsync.WithRawResponse licenses() { + return licenses.withRawResponse(); + } + /** * The {@code metrics} operations. * diff --git a/src/main/java/com/meteroid/api/CustomProperties.java b/src/main/java/com/meteroid/api/CustomProperties.java index 78506f9..d7fc015 100644 --- a/src/main/java/com/meteroid/api/CustomProperties.java +++ b/src/main/java/com/meteroid/api/CustomProperties.java @@ -199,7 +199,13 @@ MeteroidHttpClient.Exchange exchangeCreateCustomProper .build(); return client.call("POST", url) .json(customPropertyDefinitionCreateRequest) - .errors(com.meteroid.models.RestErrorResponse.class, "400", "409", "429", "500") + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "403", + "409", + "429", + "500") .options(requestOptions) .returning(CustomPropertyDefinition.class); } @@ -284,7 +290,7 @@ MeteroidHttpClient.Exchange exchangeUpdateCustomProper .build(); return client.call("PUT", url) .json(customPropertyDefinitionUpdateRequest) - .errors(com.meteroid.models.RestErrorResponse.class, "404", "429", "500") + .errors(com.meteroid.models.RestErrorResponse.class, "403", "404", "429", "500") .options(requestOptions) .returning(CustomPropertyDefinition.class); } diff --git a/src/main/java/com/meteroid/api/Licenses.java b/src/main/java/com/meteroid/api/Licenses.java new file mode 100644 index 0000000..1321109 --- /dev/null +++ b/src/main/java/com/meteroid/api/Licenses.java @@ -0,0 +1,594 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.internal.MeteroidHttpClient; +import com.meteroid.internal.Utils; +import com.meteroid.models.IssueLicenseRequest; +import com.meteroid.models.IssueLicenseResponse; +import com.meteroid.models.IssueOfflineLicenseRequest; +import com.meteroid.models.License; +import com.meteroid.models.LicenseActivationCode; +import com.meteroid.models.LicenseListResponse; +import com.meteroid.models.LicenseSigningKeysResponse; +import com.meteroid.models.OfflineLicense; +import com.meteroid.models.RevokeLicenseRequest; + +import okhttp3.HttpUrl; + +import java.util.Objects; + +/** + * The {@code licenses} operations, blocking. {@link #withRawResponse()} has the same methods + * returning the status and headers along with the body. + */ +public final class Licenses { + private final MeteroidHttpClient client; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code client}. + * + * @param client the HTTP client of the SDK + */ + public Licenses(MeteroidHttpClient client) { + this.client = client; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List licenses + * + * @return the response body + */ + public LicenseListResponse list() { + return list(LicensesListOptions.none(), RequestOptions.none()); + } + + /** + * List licenses + * + * @param options the optional parameters + * @return the response body + */ + public LicenseListResponse list(final LicensesListOptions options) { + return list(options, RequestOptions.none()); + } + + /** + * List licenses + * + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public LicenseListResponse list(final RequestOptions requestOptions) { + return list(LicensesListOptions.none(), requestOptions); + } + + /** + * List licenses + * + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public LicenseListResponse list( + final LicensesListOptions options, final RequestOptions requestOptions) { + return exchangeList(options, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeList( + final LicensesListOptions options, final RequestOptions requestOptions) { + Objects.requireNonNull(options, "options"); + HttpUrl.Builder url = client.newUrlBuilder().addPathSegments("api/v1/licenses"); + String value1 = options.customerId().orElse(null); + if (value1 != null) { + url.addQueryParameter("customer_id", value1); + } + String value2 = options.subscriptionId().orElse(null); + if (value2 != null) { + url.addQueryParameter("subscription_id", value2); + } + Boolean value3 = options.includeRevoked().orElse(null); + if (value3 != null) { + url.addQueryParameter("include_revoked", Utils.serializeQueryParam(value3)); + } + return client.call("GET", url.build()) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(LicenseListResponse.class); + } + + /** + * Issue a license + * + *

Issues a license to a customer, optionally tied to one of its subscriptions. Online, the + * license is pending until their installation activates it with the returned one-time code. + * Offline, it is returned signed at once, for an installation that can't reach the server. + * + * @param issueLicenseRequest the request body + * @return the response body + */ + public IssueLicenseResponse create(final IssueLicenseRequest issueLicenseRequest) { + return create(issueLicenseRequest, RequestOptions.none()); + } + + /** + * Issue a license + * + *

Issues a license to a customer, optionally tied to one of its subscriptions. Online, the + * license is pending until their installation activates it with the returned one-time code. + * Offline, it is returned signed at once, for an installation that can't reach the server. + * + * @param issueLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public IssueLicenseResponse create( + final IssueLicenseRequest issueLicenseRequest, final RequestOptions requestOptions) { + return exchangeCreate(issueLicenseRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeCreate( + final IssueLicenseRequest issueLicenseRequest, final RequestOptions requestOptions) { + Objects.requireNonNull(issueLicenseRequest, "body"); + HttpUrl url = client.newUrlBuilder().addPathSegments("api/v1/licenses").build(); + return client.call("POST", url) + .json(issueLicenseRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "403", + "404", + "409", + "429") + .options(requestOptions) + .returning(IssueLicenseResponse.class); + } + + /** + * Get a license + * + * @param licenseId the {@code license_id} path parameter + * @return the response body + */ + public License retrieve(final String licenseId) { + return retrieve(licenseId, RequestOptions.none()); + } + + /** + * Get a license + * + * @param licenseId the {@code license_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public License retrieve(final String licenseId, final RequestOptions requestOptions) { + return exchangeRetrieve(licenseId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRetrieve( + final String licenseId, final RequestOptions requestOptions) { + Objects.requireNonNull(licenseId, "license_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/licenses") + .addPathSegment(Utils.pathSegment("license_id", licenseId)) + .build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(License.class); + } + + /** + * Get a license's activation code + * + *

Available until the license is activated or revoked. + * + * @param licenseId the {@code license_id} path parameter + * @return the response body + */ + public LicenseActivationCode retrieveActivationCode(final String licenseId) { + return retrieveActivationCode(licenseId, RequestOptions.none()); + } + + /** + * Get a license's activation code + * + *

Available until the license is activated or revoked. + * + * @param licenseId the {@code license_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public LicenseActivationCode retrieveActivationCode( + final String licenseId, final RequestOptions requestOptions) { + return exchangeRetrieveActivationCode(licenseId, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRetrieveActivationCode( + final String licenseId, final RequestOptions requestOptions) { + Objects.requireNonNull(licenseId, "license_id"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/licenses") + .addPathSegment(Utils.pathSegment("license_id", licenseId)) + .addPathSegments("activation-code") + .build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(LicenseActivationCode.class); + } + + /** + * Issue an offline license + * + *

Signs a long-lived license for an air-gapped installation from an existing license, e.g. + * to renew an offline license before it expires. Given an instance id, binds the license to it. + * + * @param licenseId the {@code license_id} path parameter + * @param issueOfflineLicenseRequest the request body + * @return the response body + */ + public OfflineLicense offline( + final String licenseId, final IssueOfflineLicenseRequest issueOfflineLicenseRequest) { + return offline(licenseId, issueOfflineLicenseRequest, RequestOptions.none()); + } + + /** + * Issue an offline license + * + *

Signs a long-lived license for an air-gapped installation from an existing license, e.g. + * to renew an offline license before it expires. Given an instance id, binds the license to it. + * + * @param licenseId the {@code license_id} path parameter + * @param issueOfflineLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public OfflineLicense offline( + final String licenseId, + final IssueOfflineLicenseRequest issueOfflineLicenseRequest, + final RequestOptions requestOptions) { + return exchangeOffline(licenseId, issueOfflineLicenseRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeOffline( + final String licenseId, + final IssueOfflineLicenseRequest issueOfflineLicenseRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(licenseId, "license_id"); + Objects.requireNonNull(issueOfflineLicenseRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/licenses") + .addPathSegment(Utils.pathSegment("license_id", licenseId)) + .addPathSegments("offline") + .build(); + return client.call("POST", url) + .json(issueOfflineLicenseRequest) + .errors( + com.meteroid.models.RestErrorResponse.class, + "400", + "401", + "403", + "404", + "409", + "429") + .options(requestOptions) + .returning(OfflineLicense.class); + } + + /** + * Revoke a license + * + * @param licenseId the {@code license_id} path parameter + * @param revokeLicenseRequest the request body + * @return the response body + */ + public License revoke(final String licenseId, final RevokeLicenseRequest revokeLicenseRequest) { + return revoke(licenseId, revokeLicenseRequest, RequestOptions.none()); + } + + /** + * Revoke a license + * + * @param licenseId the {@code license_id} path parameter + * @param revokeLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public License revoke( + final String licenseId, + final RevokeLicenseRequest revokeLicenseRequest, + final RequestOptions requestOptions) { + return exchangeRevoke(licenseId, revokeLicenseRequest, requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeRevoke( + final String licenseId, + final RevokeLicenseRequest revokeLicenseRequest, + final RequestOptions requestOptions) { + Objects.requireNonNull(licenseId, "license_id"); + Objects.requireNonNull(revokeLicenseRequest, "body"); + HttpUrl url = + client.newUrlBuilder() + .addPathSegments("api/v1/licenses") + .addPathSegment(Utils.pathSegment("license_id", licenseId)) + .addPathSegments("revoke") + .build(); + return client.call("POST", url) + .json(revokeLicenseRequest) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "404", "429") + .options(requestOptions) + .returning(License.class); + } + + /** + * Get the licensing signing keys + * + *

The keys licenses are signed with, and the public endpoints installations talk to. + * + * @return the response body + */ + public LicenseSigningKeysResponse listLicensingSigningKeys() { + return listLicensingSigningKeys(RequestOptions.none()); + } + + /** + * Get the licensing signing keys + * + *

The keys licenses are signed with, and the public endpoints installations talk to. + * + * @param requestOptions headers, timeout and retries of this call + * @return the response body + */ + public LicenseSigningKeysResponse listLicensingSigningKeys( + final RequestOptions requestOptions) { + return exchangeListLicensingSigningKeys(requestOptions).send(); + } + + MeteroidHttpClient.Exchange exchangeListLicensingSigningKeys( + final RequestOptions requestOptions) { + HttpUrl url = + client.newUrlBuilder().addPathSegments("api/v1/licensing/signing-keys").build(); + return client.call("GET", url) + .errors(com.meteroid.models.RestErrorResponse.class, "401", "403", "429") + .options(requestOptions) + .returning(LicenseSigningKeysResponse.class); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List licenses + * + * @return the status, headers and body + */ + public ApiResponse list() { + return list(LicensesListOptions.none(), RequestOptions.none()); + } + + /** + * List licenses + * + * @param options the optional parameters + * @return the status, headers and body + */ + public ApiResponse list(final LicensesListOptions options) { + return list(options, RequestOptions.none()); + } + + /** + * List licenses + * + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list(final RequestOptions requestOptions) { + return list(LicensesListOptions.none(), requestOptions); + } + + /** + * List licenses + * + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse list( + final LicensesListOptions options, final RequestOptions requestOptions) { + return Licenses.this.exchangeList(options, requestOptions).sendRaw(); + } + + /** + * Issue a license + * + *

Issues a license to a customer, optionally tied to one of its subscriptions. Online, + * the license is pending until their installation activates it with the returned one-time + * code. Offline, it is returned signed at once, for an installation that can't reach the + * server. + * + * @param issueLicenseRequest the request body + * @return the status, headers and body + */ + public ApiResponse create( + final IssueLicenseRequest issueLicenseRequest) { + return create(issueLicenseRequest, RequestOptions.none()); + } + + /** + * Issue a license + * + *

Issues a license to a customer, optionally tied to one of its subscriptions. Online, + * the license is pending until their installation activates it with the returned one-time + * code. Offline, it is returned signed at once, for an installation that can't reach the + * server. + * + * @param issueLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse create( + final IssueLicenseRequest issueLicenseRequest, + final RequestOptions requestOptions) { + return Licenses.this.exchangeCreate(issueLicenseRequest, requestOptions).sendRaw(); + } + + /** + * Get a license + * + * @param licenseId the {@code license_id} path parameter + * @return the status, headers and body + */ + public ApiResponse retrieve(final String licenseId) { + return retrieve(licenseId, RequestOptions.none()); + } + + /** + * Get a license + * + * @param licenseId the {@code license_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieve( + final String licenseId, final RequestOptions requestOptions) { + return Licenses.this.exchangeRetrieve(licenseId, requestOptions).sendRaw(); + } + + /** + * Get a license's activation code + * + *

Available until the license is activated or revoked. + * + * @param licenseId the {@code license_id} path parameter + * @return the status, headers and body + */ + public ApiResponse retrieveActivationCode(final String licenseId) { + return retrieveActivationCode(licenseId, RequestOptions.none()); + } + + /** + * Get a license's activation code + * + *

Available until the license is activated or revoked. + * + * @param licenseId the {@code license_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse retrieveActivationCode( + final String licenseId, final RequestOptions requestOptions) { + return Licenses.this + .exchangeRetrieveActivationCode(licenseId, requestOptions) + .sendRaw(); + } + + /** + * Issue an offline license + * + *

Signs a long-lived license for an air-gapped installation from an existing license, + * e.g. to renew an offline license before it expires. Given an instance id, binds the + * license to it. + * + * @param licenseId the {@code license_id} path parameter + * @param issueOfflineLicenseRequest the request body + * @return the status, headers and body + */ + public ApiResponse offline( + final String licenseId, + final IssueOfflineLicenseRequest issueOfflineLicenseRequest) { + return offline(licenseId, issueOfflineLicenseRequest, RequestOptions.none()); + } + + /** + * Issue an offline license + * + *

Signs a long-lived license for an air-gapped installation from an existing license, + * e.g. to renew an offline license before it expires. Given an instance id, binds the + * license to it. + * + * @param licenseId the {@code license_id} path parameter + * @param issueOfflineLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse offline( + final String licenseId, + final IssueOfflineLicenseRequest issueOfflineLicenseRequest, + final RequestOptions requestOptions) { + return Licenses.this + .exchangeOffline(licenseId, issueOfflineLicenseRequest, requestOptions) + .sendRaw(); + } + + /** + * Revoke a license + * + * @param licenseId the {@code license_id} path parameter + * @param revokeLicenseRequest the request body + * @return the status, headers and body + */ + public ApiResponse revoke( + final String licenseId, final RevokeLicenseRequest revokeLicenseRequest) { + return revoke(licenseId, revokeLicenseRequest, RequestOptions.none()); + } + + /** + * Revoke a license + * + * @param licenseId the {@code license_id} path parameter + * @param revokeLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse revoke( + final String licenseId, + final RevokeLicenseRequest revokeLicenseRequest, + final RequestOptions requestOptions) { + return Licenses.this + .exchangeRevoke(licenseId, revokeLicenseRequest, requestOptions) + .sendRaw(); + } + + /** + * Get the licensing signing keys + * + *

The keys licenses are signed with, and the public endpoints installations talk to. + * + * @return the status, headers and body + */ + public ApiResponse listLicensingSigningKeys() { + return listLicensingSigningKeys(RequestOptions.none()); + } + + /** + * Get the licensing signing keys + * + *

The keys licenses are signed with, and the public endpoints installations talk to. + * + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body + */ + public ApiResponse listLicensingSigningKeys( + final RequestOptions requestOptions) { + return Licenses.this.exchangeListLicensingSigningKeys(requestOptions).sendRaw(); + } + } +} diff --git a/src/main/java/com/meteroid/api/LicensesAsync.java b/src/main/java/com/meteroid/api/LicensesAsync.java new file mode 100644 index 0000000..9158a84 --- /dev/null +++ b/src/main/java/com/meteroid/api/LicensesAsync.java @@ -0,0 +1,470 @@ +// this file is @generated +package com.meteroid.api; + +import com.meteroid.ApiResponse; +import com.meteroid.RequestOptions; +import com.meteroid.models.IssueLicenseRequest; +import com.meteroid.models.IssueLicenseResponse; +import com.meteroid.models.IssueOfflineLicenseRequest; +import com.meteroid.models.License; +import com.meteroid.models.LicenseActivationCode; +import com.meteroid.models.LicenseListResponse; +import com.meteroid.models.LicenseSigningKeysResponse; +import com.meteroid.models.OfflineLicense; +import com.meteroid.models.RevokeLicenseRequest; + +import java.util.concurrent.CompletableFuture; + +/** + * The {@code licenses} operations, without blocking: each method returns a {@link + * CompletableFuture}. Obtained from {@code client.async()}. + */ +public final class LicensesAsync { + private final Licenses sync; + private final WithRawResponse withRawResponse; + + /** + * The operations, sending through {@code sync}. + * + * @param sync the blocking operations + */ + public LicensesAsync(Licenses sync) { + this.sync = sync; + this.withRawResponse = new WithRawResponse(); + } + + /** + * The same operations, returning the status and headers along with the body. + * + * @return the operations + */ + public WithRawResponse withRawResponse() { + return withRawResponse; + } + + /** + * List licenses + * + * @return the response body, once received + */ + public CompletableFuture list() { + return list(LicensesListOptions.none(), RequestOptions.none()); + } + + /** + * List licenses + * + * @param options the optional parameters + * @return the response body, once received + */ + public CompletableFuture list(final LicensesListOptions options) { + return list(options, RequestOptions.none()); + } + + /** + * List licenses + * + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list(final RequestOptions requestOptions) { + return list(LicensesListOptions.none(), requestOptions); + } + + /** + * List licenses + * + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture list( + final LicensesListOptions options, final RequestOptions requestOptions) { + return sync.exchangeList(options, requestOptions).sendAsync(); + } + + /** + * Issue a license + * + *

Issues a license to a customer, optionally tied to one of its subscriptions. Online, the + * license is pending until their installation activates it with the returned one-time code. + * Offline, it is returned signed at once, for an installation that can't reach the server. + * + * @param issueLicenseRequest the request body + * @return the response body, once received + */ + public CompletableFuture create( + final IssueLicenseRequest issueLicenseRequest) { + return create(issueLicenseRequest, RequestOptions.none()); + } + + /** + * Issue a license + * + *

Issues a license to a customer, optionally tied to one of its subscriptions. Online, the + * license is pending until their installation activates it with the returned one-time code. + * Offline, it is returned signed at once, for an installation that can't reach the server. + * + * @param issueLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture create( + final IssueLicenseRequest issueLicenseRequest, final RequestOptions requestOptions) { + return sync.exchangeCreate(issueLicenseRequest, requestOptions).sendAsync(); + } + + /** + * Get a license + * + * @param licenseId the {@code license_id} path parameter + * @return the response body, once received + */ + public CompletableFuture retrieve(final String licenseId) { + return retrieve(licenseId, RequestOptions.none()); + } + + /** + * Get a license + * + * @param licenseId the {@code license_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieve( + final String licenseId, final RequestOptions requestOptions) { + return sync.exchangeRetrieve(licenseId, requestOptions).sendAsync(); + } + + /** + * Get a license's activation code + * + *

Available until the license is activated or revoked. + * + * @param licenseId the {@code license_id} path parameter + * @return the response body, once received + */ + public CompletableFuture retrieveActivationCode(final String licenseId) { + return retrieveActivationCode(licenseId, RequestOptions.none()); + } + + /** + * Get a license's activation code + * + *

Available until the license is activated or revoked. + * + * @param licenseId the {@code license_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture retrieveActivationCode( + final String licenseId, final RequestOptions requestOptions) { + return sync.exchangeRetrieveActivationCode(licenseId, requestOptions).sendAsync(); + } + + /** + * Issue an offline license + * + *

Signs a long-lived license for an air-gapped installation from an existing license, e.g. + * to renew an offline license before it expires. Given an instance id, binds the license to it. + * + * @param licenseId the {@code license_id} path parameter + * @param issueOfflineLicenseRequest the request body + * @return the response body, once received + */ + public CompletableFuture offline( + final String licenseId, final IssueOfflineLicenseRequest issueOfflineLicenseRequest) { + return offline(licenseId, issueOfflineLicenseRequest, RequestOptions.none()); + } + + /** + * Issue an offline license + * + *

Signs a long-lived license for an air-gapped installation from an existing license, e.g. + * to renew an offline license before it expires. Given an instance id, binds the license to it. + * + * @param licenseId the {@code license_id} path parameter + * @param issueOfflineLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture offline( + final String licenseId, + final IssueOfflineLicenseRequest issueOfflineLicenseRequest, + final RequestOptions requestOptions) { + return sync.exchangeOffline(licenseId, issueOfflineLicenseRequest, requestOptions) + .sendAsync(); + } + + /** + * Revoke a license + * + * @param licenseId the {@code license_id} path parameter + * @param revokeLicenseRequest the request body + * @return the response body, once received + */ + public CompletableFuture revoke( + final String licenseId, final RevokeLicenseRequest revokeLicenseRequest) { + return revoke(licenseId, revokeLicenseRequest, RequestOptions.none()); + } + + /** + * Revoke a license + * + * @param licenseId the {@code license_id} path parameter + * @param revokeLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture revoke( + final String licenseId, + final RevokeLicenseRequest revokeLicenseRequest, + final RequestOptions requestOptions) { + return sync.exchangeRevoke(licenseId, revokeLicenseRequest, requestOptions).sendAsync(); + } + + /** + * Get the licensing signing keys + * + *

The keys licenses are signed with, and the public endpoints installations talk to. + * + * @return the response body, once received + */ + public CompletableFuture listLicensingSigningKeys() { + return listLicensingSigningKeys(RequestOptions.none()); + } + + /** + * Get the licensing signing keys + * + *

The keys licenses are signed with, and the public endpoints installations talk to. + * + * @param requestOptions headers, timeout and retries of this call + * @return the response body, once received + */ + public CompletableFuture listLicensingSigningKeys( + final RequestOptions requestOptions) { + return sync.exchangeListLicensingSigningKeys(requestOptions).sendAsync(); + } + + /** The operations, returning the status and headers along with the body. */ + public final class WithRawResponse { + private WithRawResponse() {} + + /** + * List licenses + * + * @return the status, headers and body, once received + */ + public CompletableFuture> list() { + return list(LicensesListOptions.none(), RequestOptions.none()); + } + + /** + * List licenses + * + * @param options the optional parameters + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final LicensesListOptions options) { + return list(options, RequestOptions.none()); + } + + /** + * List licenses + * + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final RequestOptions requestOptions) { + return list(LicensesListOptions.none(), requestOptions); + } + + /** + * List licenses + * + * @param options the optional parameters + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> list( + final LicensesListOptions options, final RequestOptions requestOptions) { + return sync.exchangeList(options, requestOptions).sendRawAsync(); + } + + /** + * Issue a license + * + *

Issues a license to a customer, optionally tied to one of its subscriptions. Online, + * the license is pending until their installation activates it with the returned one-time + * code. Offline, it is returned signed at once, for an installation that can't reach the + * server. + * + * @param issueLicenseRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final IssueLicenseRequest issueLicenseRequest) { + return create(issueLicenseRequest, RequestOptions.none()); + } + + /** + * Issue a license + * + *

Issues a license to a customer, optionally tied to one of its subscriptions. Online, + * the license is pending until their installation activates it with the returned one-time + * code. Offline, it is returned signed at once, for an installation that can't reach the + * server. + * + * @param issueLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> create( + final IssueLicenseRequest issueLicenseRequest, + final RequestOptions requestOptions) { + return sync.exchangeCreate(issueLicenseRequest, requestOptions).sendRawAsync(); + } + + /** + * Get a license + * + * @param licenseId the {@code license_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve(final String licenseId) { + return retrieve(licenseId, RequestOptions.none()); + } + + /** + * Get a license + * + * @param licenseId the {@code license_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieve( + final String licenseId, final RequestOptions requestOptions) { + return sync.exchangeRetrieve(licenseId, requestOptions).sendRawAsync(); + } + + /** + * Get a license's activation code + * + *

Available until the license is activated or revoked. + * + * @param licenseId the {@code license_id} path parameter + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieveActivationCode( + final String licenseId) { + return retrieveActivationCode(licenseId, RequestOptions.none()); + } + + /** + * Get a license's activation code + * + *

Available until the license is activated or revoked. + * + * @param licenseId the {@code license_id} path parameter + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> retrieveActivationCode( + final String licenseId, final RequestOptions requestOptions) { + return sync.exchangeRetrieveActivationCode(licenseId, requestOptions).sendRawAsync(); + } + + /** + * Issue an offline license + * + *

Signs a long-lived license for an air-gapped installation from an existing license, + * e.g. to renew an offline license before it expires. Given an instance id, binds the + * license to it. + * + * @param licenseId the {@code license_id} path parameter + * @param issueOfflineLicenseRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> offline( + final String licenseId, + final IssueOfflineLicenseRequest issueOfflineLicenseRequest) { + return offline(licenseId, issueOfflineLicenseRequest, RequestOptions.none()); + } + + /** + * Issue an offline license + * + *

Signs a long-lived license for an air-gapped installation from an existing license, + * e.g. to renew an offline license before it expires. Given an instance id, binds the + * license to it. + * + * @param licenseId the {@code license_id} path parameter + * @param issueOfflineLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> offline( + final String licenseId, + final IssueOfflineLicenseRequest issueOfflineLicenseRequest, + final RequestOptions requestOptions) { + return sync.exchangeOffline(licenseId, issueOfflineLicenseRequest, requestOptions) + .sendRawAsync(); + } + + /** + * Revoke a license + * + * @param licenseId the {@code license_id} path parameter + * @param revokeLicenseRequest the request body + * @return the status, headers and body, once received + */ + public CompletableFuture> revoke( + final String licenseId, final RevokeLicenseRequest revokeLicenseRequest) { + return revoke(licenseId, revokeLicenseRequest, RequestOptions.none()); + } + + /** + * Revoke a license + * + * @param licenseId the {@code license_id} path parameter + * @param revokeLicenseRequest the request body + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> revoke( + final String licenseId, + final RevokeLicenseRequest revokeLicenseRequest, + final RequestOptions requestOptions) { + return sync.exchangeRevoke(licenseId, revokeLicenseRequest, requestOptions) + .sendRawAsync(); + } + + /** + * Get the licensing signing keys + * + *

The keys licenses are signed with, and the public endpoints installations talk to. + * + * @return the status, headers and body, once received + */ + public CompletableFuture> + listLicensingSigningKeys() { + return listLicensingSigningKeys(RequestOptions.none()); + } + + /** + * Get the licensing signing keys + * + *

The keys licenses are signed with, and the public endpoints installations talk to. + * + * @param requestOptions headers, timeout and retries of this call + * @return the status, headers and body, once received + */ + public CompletableFuture> listLicensingSigningKeys( + final RequestOptions requestOptions) { + return sync.exchangeListLicensingSigningKeys(requestOptions).sendRawAsync(); + } + } +} diff --git a/src/main/java/com/meteroid/api/LicensesListOptions.java b/src/main/java/com/meteroid/api/LicensesListOptions.java new file mode 100644 index 0000000..a4ac000 --- /dev/null +++ b/src/main/java/com/meteroid/api/LicensesListOptions.java @@ -0,0 +1,158 @@ +// this file is @generated +package com.meteroid.api; + +import java.util.Objects; +import java.util.Optional; + +/** Optional parameters of {@code list}, immutable: build them with {@link #builder()}. */ +public final class LicensesListOptions { + private final String customerId; + private final String subscriptionId; + private final Boolean includeRevoked; + + private LicensesListOptions(Builder builder) { + this.customerId = builder.customerId; + this.subscriptionId = builder.subscriptionId; + this.includeRevoked = builder.includeRevoked; + } + + /** + * A builder of parameters. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * No parameters. + * + * @return empty parameters + */ + public static LicensesListOptions none() { + return builder().build(); + } + + /** + * A builder starting from these parameters. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.customerId = customerId; + builder.subscriptionId = subscriptionId; + builder.includeRevoked = includeRevoked; + return builder; + } + + /** + * Filter by customer ID or alias + * + * @return the value, empty when unset + */ + public Optional customerId() { + return Optional.ofNullable(customerId); + } + + /** + * The {@code subscription_id} parameter. + * + * @return the value, empty when unset + */ + public Optional subscriptionId() { + return Optional.ofNullable(subscriptionId); + } + + /** + * Include revoked licenses. Default: false. + * + * @return the value, empty when unset + */ + public Optional includeRevoked() { + return Optional.ofNullable(includeRevoked); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LicensesListOptions that = (LicensesListOptions) o; + return Objects.equals(customerId, that.customerId) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(includeRevoked, that.includeRevoked); + } + + @Override + public int hashCode() { + return Objects.hash(customerId, subscriptionId, includeRevoked); + } + + @Override + public String toString() { + return "LicensesListOptions{" + + "customerId=" + + customerId + + ", subscriptionId=" + + subscriptionId + + ", includeRevoked=" + + includeRevoked + + "}"; + } + + /** Builds {@link LicensesListOptions}. */ + public static final class Builder { + private String customerId; + private String subscriptionId; + private Boolean includeRevoked; + + private Builder() {} + + /** + * Filter by customer ID or alias + * + * @param customerId the value, null to leave it out + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * The {@code subscription_id} parameter. + * + * @param subscriptionId the value, null to leave it out + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** + * Include revoked licenses. Default: false. + * + * @param includeRevoked the value, null to leave it out + * @return this builder + */ + public Builder includeRevoked(Boolean includeRevoked) { + this.includeRevoked = includeRevoked; + return this; + } + + /** + * The parameters. + * + * @return immutable parameters + */ + public LicensesListOptions build() { + return new LicensesListOptions(this); + } + } +} diff --git a/src/main/java/com/meteroid/models/IssueLicenseRequest.java b/src/main/java/com/meteroid/models/IssueLicenseRequest.java new file mode 100644 index 0000000..d0ef579 --- /dev/null +++ b/src/main/java/com/meteroid/models/IssueLicenseRequest.java @@ -0,0 +1,336 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class IssueLicenseRequest { + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("instance_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField instanceId = JsonField.missing(); + + @JsonProperty("offline") + private Boolean offline; + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + @JsonProperty("validity_days") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField validityDays = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private IssueLicenseRequest() {} + + private IssueLicenseRequest(Builder builder) { + this.customerId = builder.customerId; + this.instanceId = builder.instanceId; + this.offline = builder.offline; + this.subscriptionId = builder.subscriptionId; + this.validityDays = builder.validityDays; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code IssueLicenseRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.customerId = customerId; + builder.instanceId = instanceId; + builder.offline = offline; + builder.subscriptionId = subscriptionId; + builder.validityDays = validityDays; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Customer ID or alias + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * Offline only. The installation's id as it reports it, up to 255 characters without spaces: + * the license names it (aud) and stays bound to it. Without one, the license is + * not tied to an installation. + * + * @return the value, empty when unset or null + */ + public Optional instanceId() { + return instanceId.asOptional(); + } + + /** + * Delivers the license at once as a signed offline license, for an installation that can't + * reach the license server: no activation code, no refresh. Default: false. + * + * @return the value, empty when unset + */ + public Optional offline() { + return Optional.ofNullable(offline); + } + + /** + * Ties the license to this subscription of the customer: it is renewed while the subscription + * is paid, and carries its plan's entitlements. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * Online: lifetime of each license token the installation refreshes, 1 to 31 days. Default: 7. + * Offline: lifetime of the signed license, 1 to 400 days. Default: 365. + * + * @return the value, empty when unset or null + */ + public Optional validityDays() { + return validityDays.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IssueLicenseRequest that = (IssueLicenseRequest) o; + return Objects.equals(customerId, that.customerId) + && Objects.equals(instanceId, that.instanceId) + && Objects.equals(offline, that.offline) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(validityDays, that.validityDays) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + customerId, + instanceId, + offline, + subscriptionId, + validityDays, + additionalProperties); + } + + @Override + public String toString() { + return "IssueLicenseRequest{" + + "customerId=" + + customerId + + ", instanceId=" + + instanceId + + ", offline=" + + offline + + ", subscriptionId=" + + subscriptionId + + ", validityDays=" + + validityDays + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link IssueLicenseRequest}. */ + public static final class Builder { + private String customerId; + private JsonField instanceId = JsonField.missing(); + private Boolean offline; + private JsonField subscriptionId = JsonField.missing(); + private JsonField validityDays = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Customer ID or alias + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * Offline only. The installation's id as it reports it, up to 255 characters without + * spaces: the license names it (aud) and stays bound to it. Without one, the + * license is not tied to an installation. + * + * @param instanceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder instanceId(String instanceId) { + this.instanceId = JsonField.ofNullable(instanceId); + return this; + } + + /** + * Delivers the license at once as a signed offline license, for an installation that can't + * reach the license server: no activation code, no refresh. Default: false. + * + * @param offline the value + * @return this builder + */ + public Builder offline(Boolean offline) { + this.offline = offline; + return this; + } + + /** + * Ties the license to this subscription of the customer: it is renewed while the + * subscription is paid, and carries its plan's entitlements. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * Online: lifetime of each license token the installation refreshes, 1 to 31 days. Default: + * 7. Offline: lifetime of the signed license, 1 to 400 days. Default: 365. + * + * @param validityDays the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder validityDays(Integer validityDays) { + this.validityDays = JsonField.ofNullable(validityDays); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code IssueLicenseRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public IssueLicenseRequest build() { + Utils.checkRequired(customerId, "customer_id"); + return new IssueLicenseRequest(this); + } + } + + /** + * Parse {@code json} as {@code IssueLicenseRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static IssueLicenseRequest fromJson(String json) { + return Utils.parse(json, IssueLicenseRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/IssueLicenseResponse.java b/src/main/java/com/meteroid/models/IssueLicenseResponse.java new file mode 100644 index 0000000..c27c61a --- /dev/null +++ b/src/main/java/com/meteroid/models/IssueLicenseResponse.java @@ -0,0 +1,261 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class IssueLicenseResponse { + @JsonProperty("activation_code") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField activationCode = JsonField.missing(); + + @JsonProperty("license") + private License license; + + @JsonProperty("offline_license") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField offlineLicense = JsonField.missing(); + + private final Map additionalProperties = new LinkedHashMap<>(); + + private IssueLicenseResponse() {} + + private IssueLicenseResponse(Builder builder) { + this.activationCode = builder.activationCode; + this.license = builder.license; + this.offlineLicense = builder.offlineLicense; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code IssueLicenseResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.activationCode = activationCode; + builder.license = license; + builder.offlineLicense = offlineLicense; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Online: one-time code the customer enters in their installation to activate the license. + * + * @return the value, empty when unset or null + */ + public Optional activationCode() { + return activationCode.asOptional(); + } + + /** + * The {@code license} property. + * + * @return the value, never null + */ + public License license() { + return Utils.required(license, "license"); + } + + /** + * Offline: the signed license (a JWT) to install in the installation. + * + * @return the value, empty when unset or null + */ + public Optional offlineLicense() { + return offlineLicense.asOptional(); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IssueLicenseResponse that = (IssueLicenseResponse) o; + return Objects.equals(activationCode, that.activationCode) + && Objects.equals(license, that.license) + && Objects.equals(offlineLicense, that.offlineLicense) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(activationCode, license, offlineLicense, additionalProperties); + } + + @Override + public String toString() { + return "IssueLicenseResponse{" + + "activationCode=" + + activationCode + + ", license=" + + license + + ", offlineLicense=" + + offlineLicense + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link IssueLicenseResponse}. */ + public static final class Builder { + private JsonField activationCode = JsonField.missing(); + private License license; + private JsonField offlineLicense = JsonField.missing(); + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Online: one-time code the customer enters in their installation to activate the license. + * + * @param activationCode the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder activationCode(String activationCode) { + this.activationCode = JsonField.ofNullable(activationCode); + return this; + } + + /** + * The {@code license} property. + * + * @param license the value + * @return this builder + */ + public Builder license(License license) { + this.license = license; + return this; + } + + /** + * Offline: the signed license (a JWT) to install in the installation. + * + * @param offlineLicense the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder offlineLicense(String offlineLicense) { + this.offlineLicense = JsonField.ofNullable(offlineLicense); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code IssueLicenseResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public IssueLicenseResponse build() { + Utils.checkRequired(license, "license"); + return new IssueLicenseResponse(this); + } + } + + /** + * Parse {@code json} as {@code IssueLicenseResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static IssueLicenseResponse fromJson(String json) { + return Utils.parse(json, IssueLicenseResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/IssueOfflineLicenseRequest.java b/src/main/java/com/meteroid/models/IssueOfflineLicenseRequest.java new file mode 100644 index 0000000..2047645 --- /dev/null +++ b/src/main/java/com/meteroid/models/IssueOfflineLicenseRequest.java @@ -0,0 +1,235 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class IssueOfflineLicenseRequest { + @JsonProperty("instance_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField instanceId = JsonField.missing(); + + @JsonProperty("valid_days") + private Integer validDays; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private IssueOfflineLicenseRequest() {} + + private IssueOfflineLicenseRequest(Builder builder) { + this.instanceId = builder.instanceId; + this.validDays = builder.validDays; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code IssueOfflineLicenseRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.instanceId = instanceId; + builder.validDays = validDays; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The installation's id as it reports it, up to 255 characters without spaces: the license + * names it (aud) and stays bound to it. Without one, the license is not tied to + * one. + * + * @return the value, empty when unset or null + */ + public Optional instanceId() { + return instanceId.asOptional(); + } + + /** + * Lifetime of the offline license, 1 to 400 days. + * + * @return the value, never null + */ + public Integer validDays() { + return Utils.required(validDays, "valid_days"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IssueOfflineLicenseRequest that = (IssueOfflineLicenseRequest) o; + return Objects.equals(instanceId, that.instanceId) + && Objects.equals(validDays, that.validDays) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(instanceId, validDays, additionalProperties); + } + + @Override + public String toString() { + return "IssueOfflineLicenseRequest{" + + "instanceId=" + + instanceId + + ", validDays=" + + validDays + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link IssueOfflineLicenseRequest}. */ + public static final class Builder { + private JsonField instanceId = JsonField.missing(); + private Integer validDays; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The installation's id as it reports it, up to 255 characters without spaces: the license + * names it (aud) and stays bound to it. Without one, the license is not tied + * to one. + * + * @param instanceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder instanceId(String instanceId) { + this.instanceId = JsonField.ofNullable(instanceId); + return this; + } + + /** + * Lifetime of the offline license, 1 to 400 days. + * + * @param validDays the value + * @return this builder + */ + public Builder validDays(Integer validDays) { + this.validDays = validDays; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code IssueOfflineLicenseRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public IssueOfflineLicenseRequest build() { + Utils.checkRequired(validDays, "valid_days"); + return new IssueOfflineLicenseRequest(this); + } + } + + /** + * Parse {@code json} as {@code IssueOfflineLicenseRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static IssueOfflineLicenseRequest fromJson(String json) { + return Utils.parse(json, IssueOfflineLicenseRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/License.java b/src/main/java/com/meteroid/models/License.java new file mode 100644 index 0000000..460ca3b --- /dev/null +++ b/src/main/java/com/meteroid/models/License.java @@ -0,0 +1,642 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class License { + @JsonProperty("auto_issued") + private Boolean autoIssued; + + @JsonProperty("created_at") + private OffsetDateTime createdAt; + + @JsonProperty("customer_id") + private String customerId; + + @JsonProperty("customer_name") + private String customerName; + + @JsonProperty("has_activation_code") + private Boolean hasActivationCode; + + @JsonProperty("id") + private String id; + + @JsonProperty("instance_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField instanceId = JsonField.missing(); + + @JsonProperty("last_refreshed_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField lastRefreshedAt = JsonField.missing(); + + @JsonProperty("offline") + private Boolean offline; + + @JsonProperty("plan_name") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField planName = JsonField.missing(); + + @JsonProperty("revoked_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField revokedAt = JsonField.missing(); + + @JsonProperty("revoked_immediately") + private Boolean revokedImmediately; + + @JsonProperty("status") + private LicenseStatus status; + + @JsonProperty("subscription_id") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField subscriptionId = JsonField.missing(); + + @JsonProperty("validity_days") + private Integer validityDays; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private License() {} + + private License(Builder builder) { + this.autoIssued = builder.autoIssued; + this.createdAt = builder.createdAt; + this.customerId = builder.customerId; + this.customerName = builder.customerName; + this.hasActivationCode = builder.hasActivationCode; + this.id = builder.id; + this.instanceId = builder.instanceId; + this.lastRefreshedAt = builder.lastRefreshedAt; + this.offline = builder.offline; + this.planName = builder.planName; + this.revokedAt = builder.revokedAt; + this.revokedImmediately = builder.revokedImmediately; + this.status = builder.status; + this.subscriptionId = builder.subscriptionId; + this.validityDays = builder.validityDays; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code License}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.autoIssued = autoIssued; + builder.createdAt = createdAt; + builder.customerId = customerId; + builder.customerName = customerName; + builder.hasActivationCode = hasActivationCode; + builder.id = id; + builder.instanceId = instanceId; + builder.lastRefreshedAt = lastRefreshedAt; + builder.offline = offline; + builder.planName = planName; + builder.revokedAt = revokedAt; + builder.revokedImmediately = revokedImmediately; + builder.status = status; + builder.subscriptionId = subscriptionId; + builder.validityDays = validityDays; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Issued automatically for a subscription to a plan that issues licenses. + * + * @return the value, never null + */ + public Boolean autoIssued() { + return Utils.required(autoIssued, "auto_issued"); + } + + /** + * The {@code created_at} property. + * + * @return the value, never null + */ + public OffsetDateTime createdAt() { + return Utils.required(createdAt, "created_at"); + } + + /** + * The {@code customer_id} property. + * + * @return the value, never null + */ + public String customerId() { + return Utils.required(customerId, "customer_id"); + } + + /** + * The {@code customer_name} property. + * + * @return the value, never null + */ + public String customerName() { + return Utils.required(customerName, "customer_name"); + } + + /** + * Whether the activation code can still be retrieved: only until activation or revocation. + * + * @return the value, never null + */ + public Boolean hasActivationCode() { + return Utils.required(hasActivationCode, "has_activation_code"); + } + + /** + * The {@code id} property. + * + * @return the value, never null + */ + public String id() { + return Utils.required(id, "id"); + } + + /** + * The installation the license is bound to, once activated. + * + * @return the value, empty when unset or null + */ + public Optional instanceId() { + return instanceId.asOptional(); + } + + /** + * The {@code last_refreshed_at} property. + * + * @return the value, empty when unset or null + */ + public Optional lastRefreshedAt() { + return lastRefreshedAt.asOptional(); + } + + /** + * Issued as a signed offline license: never activated nor refreshed. + * + * @return the value, never null + */ + public Boolean offline() { + return Utils.required(offline, "offline"); + } + + /** + * The {@code plan_name} property. + * + * @return the value, empty when unset or null + */ + public Optional planName() { + return planName.asOptional(); + } + + /** + * The {@code revoked_at} property. + * + * @return the value, empty when unset or null + */ + public Optional revokedAt() { + return revokedAt.asOptional(); + } + + /** + * Revoked to stop at once: the installation drops its license on its next refresh instead of + * keeping it until it expires. + * + * @return the value, never null + */ + public Boolean revokedImmediately() { + return Utils.required(revokedImmediately, "revoked_immediately"); + } + + /** + * The {@code status} property. + * + * @return the value, never null + */ + public LicenseStatus status() { + return Utils.required(status, "status"); + } + + /** + * The {@code subscription_id} property. + * + * @return the value, empty when unset or null + */ + public Optional subscriptionId() { + return subscriptionId.asOptional(); + } + + /** + * Lifetime of each license token the installation receives on refresh; for an offline license, + * the lifetime it was issued with. + * + * @return the value, never null + */ + public Integer validityDays() { + return Utils.required(validityDays, "validity_days"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + License that = (License) o; + return Objects.equals(autoIssued, that.autoIssued) + && Objects.equals(createdAt, that.createdAt) + && Objects.equals(customerId, that.customerId) + && Objects.equals(customerName, that.customerName) + && Objects.equals(hasActivationCode, that.hasActivationCode) + && Objects.equals(id, that.id) + && Objects.equals(instanceId, that.instanceId) + && Objects.equals(lastRefreshedAt, that.lastRefreshedAt) + && Objects.equals(offline, that.offline) + && Objects.equals(planName, that.planName) + && Objects.equals(revokedAt, that.revokedAt) + && Objects.equals(revokedImmediately, that.revokedImmediately) + && Objects.equals(status, that.status) + && Objects.equals(subscriptionId, that.subscriptionId) + && Objects.equals(validityDays, that.validityDays) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + autoIssued, + createdAt, + customerId, + customerName, + hasActivationCode, + id, + instanceId, + lastRefreshedAt, + offline, + planName, + revokedAt, + revokedImmediately, + status, + subscriptionId, + validityDays, + additionalProperties); + } + + @Override + public String toString() { + return "License{" + + "autoIssued=" + + autoIssued + + ", createdAt=" + + createdAt + + ", customerId=" + + customerId + + ", customerName=" + + customerName + + ", hasActivationCode=" + + hasActivationCode + + ", id=" + + id + + ", instanceId=" + + instanceId + + ", lastRefreshedAt=" + + lastRefreshedAt + + ", offline=" + + offline + + ", planName=" + + planName + + ", revokedAt=" + + revokedAt + + ", revokedImmediately=" + + revokedImmediately + + ", status=" + + status + + ", subscriptionId=" + + subscriptionId + + ", validityDays=" + + validityDays + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link License}. */ + public static final class Builder { + private Boolean autoIssued; + private OffsetDateTime createdAt; + private String customerId; + private String customerName; + private Boolean hasActivationCode; + private String id; + private JsonField instanceId = JsonField.missing(); + private JsonField lastRefreshedAt = JsonField.missing(); + private Boolean offline; + private JsonField planName = JsonField.missing(); + private JsonField revokedAt = JsonField.missing(); + private Boolean revokedImmediately; + private LicenseStatus status; + private JsonField subscriptionId = JsonField.missing(); + private Integer validityDays; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Issued automatically for a subscription to a plan that issues licenses. + * + * @param autoIssued the value + * @return this builder + */ + public Builder autoIssued(Boolean autoIssued) { + this.autoIssued = autoIssued; + return this; + } + + /** + * The {@code created_at} property. + * + * @param createdAt the value + * @return this builder + */ + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The {@code customer_id} property. + * + * @param customerId the value + * @return this builder + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * The {@code customer_name} property. + * + * @param customerName the value + * @return this builder + */ + public Builder customerName(String customerName) { + this.customerName = customerName; + return this; + } + + /** + * Whether the activation code can still be retrieved: only until activation or revocation. + * + * @param hasActivationCode the value + * @return this builder + */ + public Builder hasActivationCode(Boolean hasActivationCode) { + this.hasActivationCode = hasActivationCode; + return this; + } + + /** + * The {@code id} property. + * + * @param id the value + * @return this builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * The installation the license is bound to, once activated. + * + * @param instanceId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder instanceId(String instanceId) { + this.instanceId = JsonField.ofNullable(instanceId); + return this; + } + + /** + * The {@code last_refreshed_at} property. + * + * @param lastRefreshedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder lastRefreshedAt(OffsetDateTime lastRefreshedAt) { + this.lastRefreshedAt = JsonField.ofNullable(lastRefreshedAt); + return this; + } + + /** + * Issued as a signed offline license: never activated nor refreshed. + * + * @param offline the value + * @return this builder + */ + public Builder offline(Boolean offline) { + this.offline = offline; + return this; + } + + /** + * The {@code plan_name} property. + * + * @param planName the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder planName(String planName) { + this.planName = JsonField.ofNullable(planName); + return this; + } + + /** + * The {@code revoked_at} property. + * + * @param revokedAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder revokedAt(OffsetDateTime revokedAt) { + this.revokedAt = JsonField.ofNullable(revokedAt); + return this; + } + + /** + * Revoked to stop at once: the installation drops its license on its next refresh instead + * of keeping it until it expires. + * + * @param revokedImmediately the value + * @return this builder + */ + public Builder revokedImmediately(Boolean revokedImmediately) { + this.revokedImmediately = revokedImmediately; + return this; + } + + /** + * The {@code status} property. + * + * @param status the value + * @return this builder + */ + public Builder status(LicenseStatus status) { + this.status = status; + return this; + } + + /** + * The {@code subscription_id} property. + * + * @param subscriptionId the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder subscriptionId(String subscriptionId) { + this.subscriptionId = JsonField.ofNullable(subscriptionId); + return this; + } + + /** + * Lifetime of each license token the installation receives on refresh; for an offline + * license, the lifetime it was issued with. + * + * @param validityDays the value + * @return this builder + */ + public Builder validityDays(Integer validityDays) { + this.validityDays = validityDays; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code License}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public License build() { + Utils.checkRequired(autoIssued, "auto_issued"); + Utils.checkRequired(createdAt, "created_at"); + Utils.checkRequired(customerId, "customer_id"); + Utils.checkRequired(customerName, "customer_name"); + Utils.checkRequired(hasActivationCode, "has_activation_code"); + Utils.checkRequired(id, "id"); + Utils.checkRequired(offline, "offline"); + Utils.checkRequired(revokedImmediately, "revoked_immediately"); + Utils.checkRequired(status, "status"); + Utils.checkRequired(validityDays, "validity_days"); + return new License(this); + } + } + + /** + * Parse {@code json} as {@code License}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static License fromJson(String json) { + return Utils.parse(json, License.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/LicenseActivationCode.java b/src/main/java/com/meteroid/models/LicenseActivationCode.java new file mode 100644 index 0000000..ac6cbd0 --- /dev/null +++ b/src/main/java/com/meteroid/models/LicenseActivationCode.java @@ -0,0 +1,199 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class LicenseActivationCode { + @JsonProperty("activation_code") + private String activationCode; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private LicenseActivationCode() {} + + private LicenseActivationCode(Builder builder) { + this.activationCode = builder.activationCode; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code LicenseActivationCode}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.activationCode = activationCode; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code activation_code} property. + * + * @return the value, never null + */ + public String activationCode() { + return Utils.required(activationCode, "activation_code"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LicenseActivationCode that = (LicenseActivationCode) o; + return Objects.equals(activationCode, that.activationCode) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(activationCode, additionalProperties); + } + + @Override + public String toString() { + return "LicenseActivationCode{" + + "activationCode=" + + activationCode + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link LicenseActivationCode}. */ + public static final class Builder { + private String activationCode; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code activation_code} property. + * + * @param activationCode the value + * @return this builder + */ + public Builder activationCode(String activationCode) { + this.activationCode = activationCode; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code LicenseActivationCode}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public LicenseActivationCode build() { + Utils.checkRequired(activationCode, "activation_code"); + return new LicenseActivationCode(this); + } + } + + /** + * Parse {@code json} as {@code LicenseActivationCode}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static LicenseActivationCode fromJson(String json) { + return Utils.parse(json, LicenseActivationCode.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/LicenseListResponse.java b/src/main/java/com/meteroid/models/LicenseListResponse.java new file mode 100644 index 0000000..dab1160 --- /dev/null +++ b/src/main/java/com/meteroid/models/LicenseListResponse.java @@ -0,0 +1,215 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class LicenseListResponse { + @JsonProperty("data") + private List data; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private LicenseListResponse() {} + + private LicenseListResponse(Builder builder) { + this.data = Utils.copyList(builder.data); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code LicenseListResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.data = Utils.mutableList(data); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code data} property. + * + * @return the value, never null + */ + public List data() { + return Utils.required(data, "data"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LicenseListResponse that = (LicenseListResponse) o; + return Objects.equals(data, that.data) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + return "LicenseListResponse{" + + "data=" + + data + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link LicenseListResponse}. */ + public static final class Builder { + private List data; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code data} property. + * + * @param data the value + * @return this builder + */ + public Builder data(List data) { + this.data = Utils.mutableList(data); + return this; + } + + /** + * Adds an item to {@code data}. + * + * @param item the item + * @return this builder + */ + public Builder addDataItem(License item) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code LicenseListResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public LicenseListResponse build() { + Utils.checkRequired(data, "data"); + return new LicenseListResponse(this); + } + } + + /** + * Parse {@code json} as {@code LicenseListResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static LicenseListResponse fromJson(String json) { + return Utils.parse(json, LicenseListResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/LicenseSigningKey.java b/src/main/java/com/meteroid/models/LicenseSigningKey.java new file mode 100644 index 0000000..8b6b136 --- /dev/null +++ b/src/main/java/com/meteroid/models/LicenseSigningKey.java @@ -0,0 +1,322 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.JsonField; +import com.meteroid.internal.Utils; + +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class LicenseSigningKey { + @JsonProperty("created_at") + private OffsetDateTime createdAt; + + @JsonProperty("kid") + private String kid; + + @JsonProperty("public_key_pem") + private String publicKeyPem; + + @JsonProperty("retired_at") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private JsonField retiredAt = JsonField.missing(); + + @JsonProperty("status") + private LicenseSigningKeyStatus status; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private LicenseSigningKey() {} + + private LicenseSigningKey(Builder builder) { + this.createdAt = builder.createdAt; + this.kid = builder.kid; + this.publicKeyPem = builder.publicKeyPem; + this.retiredAt = builder.retiredAt; + this.status = builder.status; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code LicenseSigningKey}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.createdAt = createdAt; + builder.kid = kid; + builder.publicKeyPem = publicKeyPem; + builder.retiredAt = retiredAt; + builder.status = status; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code created_at} property. + * + * @return the value, never null + */ + public OffsetDateTime createdAt() { + return Utils.required(createdAt, "created_at"); + } + + /** + * The key id, the kid header of the licenses it signs. + * + * @return the value, never null + */ + public String kid() { + return Utils.required(kid, "kid"); + } + + /** + * Ed25519 public key, PEM-encoded. + * + * @return the value, never null + */ + public String publicKeyPem() { + return Utils.required(publicKeyPem, "public_key_pem"); + } + + /** + * The {@code retired_at} property. + * + * @return the value, empty when unset or null + */ + public Optional retiredAt() { + return retiredAt.asOptional(); + } + + /** + * The {@code status} property. + * + * @return the value, never null + */ + public LicenseSigningKeyStatus status() { + return Utils.required(status, "status"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LicenseSigningKey that = (LicenseSigningKey) o; + return Objects.equals(createdAt, that.createdAt) + && Objects.equals(kid, that.kid) + && Objects.equals(publicKeyPem, that.publicKeyPem) + && Objects.equals(retiredAt, that.retiredAt) + && Objects.equals(status, that.status) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createdAt, kid, publicKeyPem, retiredAt, status, additionalProperties); + } + + @Override + public String toString() { + return "LicenseSigningKey{" + + "createdAt=" + + createdAt + + ", kid=" + + kid + + ", publicKeyPem=" + + publicKeyPem + + ", retiredAt=" + + retiredAt + + ", status=" + + status + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link LicenseSigningKey}. */ + public static final class Builder { + private OffsetDateTime createdAt; + private String kid; + private String publicKeyPem; + private JsonField retiredAt = JsonField.missing(); + private LicenseSigningKeyStatus status; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code created_at} property. + * + * @param createdAt the value + * @return this builder + */ + public Builder createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The key id, the kid header of the licenses it signs. + * + * @param kid the value + * @return this builder + */ + public Builder kid(String kid) { + this.kid = kid; + return this; + } + + /** + * Ed25519 public key, PEM-encoded. + * + * @param publicKeyPem the value + * @return this builder + */ + public Builder publicKeyPem(String publicKeyPem) { + this.publicKeyPem = publicKeyPem; + return this; + } + + /** + * The {@code retired_at} property. + * + * @param retiredAt the value, null to send an explicit {@code null} + * @return this builder + */ + public Builder retiredAt(OffsetDateTime retiredAt) { + this.retiredAt = JsonField.ofNullable(retiredAt); + return this; + } + + /** + * The {@code status} property. + * + * @param status the value + * @return this builder + */ + public Builder status(LicenseSigningKeyStatus status) { + this.status = status; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code LicenseSigningKey}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public LicenseSigningKey build() { + Utils.checkRequired(createdAt, "created_at"); + Utils.checkRequired(kid, "kid"); + Utils.checkRequired(publicKeyPem, "public_key_pem"); + Utils.checkRequired(status, "status"); + return new LicenseSigningKey(this); + } + } + + /** + * Parse {@code json} as {@code LicenseSigningKey}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static LicenseSigningKey fromJson(String json) { + return Utils.parse(json, LicenseSigningKey.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/LicenseSigningKeyStatus.java b/src/main/java/com/meteroid/models/LicenseSigningKeyStatus.java new file mode 100644 index 0000000..46d7f5f --- /dev/null +++ b/src/main/java/com/meteroid/models/LicenseSigningKeyStatus.java @@ -0,0 +1,128 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class LicenseSigningKeyStatus implements ToQueryParam { + /** The value {@code "ACTIVE"}. */ + public static final LicenseSigningKeyStatus ACTIVE = + new LicenseSigningKeyStatus("ACTIVE", Value.ACTIVE); + + /** The value {@code "RETIRED"}. */ + public static final LicenseSigningKeyStatus RETIRED = + new LicenseSigningKeyStatus("RETIRED", Value.RETIRED); + + private static final Map constants = + Map.ofEntries(Map.entry("ACTIVE", ACTIVE), Map.entry("RETIRED", RETIRED)); + + private final String value; + private final Value variant; + + private LicenseSigningKeyStatus(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown LicenseSigningKeyStatus holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static LicenseSigningKeyStatus of(String value) { + LicenseSigningKeyStatus constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new LicenseSigningKeyStatus(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown LicenseSigningKeyStatus: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof LicenseSigningKeyStatus + && Objects.equals(value, ((LicenseSigningKeyStatus) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code ACTIVE} constant. */ + ACTIVE, + /** The {@code RETIRED} constant. */ + RETIRED + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code ACTIVE} constant. */ + ACTIVE, + /** The {@code RETIRED} constant. */ + RETIRED, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/LicenseSigningKeysResponse.java b/src/main/java/com/meteroid/models/LicenseSigningKeysResponse.java new file mode 100644 index 0000000..97649fa --- /dev/null +++ b/src/main/java/com/meteroid/models/LicenseSigningKeysResponse.java @@ -0,0 +1,245 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class LicenseSigningKeysResponse { + @JsonProperty("endpoints") + private LicensingEndpoints endpoints; + + @JsonProperty("keys") + private List keys; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private LicenseSigningKeysResponse() {} + + private LicenseSigningKeysResponse(Builder builder) { + this.endpoints = builder.endpoints; + this.keys = Utils.copyList(builder.keys); + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code LicenseSigningKeysResponse}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.endpoints = endpoints; + builder.keys = Utils.mutableList(keys); + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code endpoints} property. + * + * @return the value, never null + */ + public LicensingEndpoints endpoints() { + return Utils.required(endpoints, "endpoints"); + } + + /** + * Active key first. The first key is created on first issue. + * + * @return the value, never null + */ + public List keys() { + return Utils.required(keys, "keys"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LicenseSigningKeysResponse that = (LicenseSigningKeysResponse) o; + return Objects.equals(endpoints, that.endpoints) + && Objects.equals(keys, that.keys) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(endpoints, keys, additionalProperties); + } + + @Override + public String toString() { + return "LicenseSigningKeysResponse{" + + "endpoints=" + + endpoints + + ", keys=" + + keys + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link LicenseSigningKeysResponse}. */ + public static final class Builder { + private LicensingEndpoints endpoints; + private List keys; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code endpoints} property. + * + * @param endpoints the value + * @return this builder + */ + public Builder endpoints(LicensingEndpoints endpoints) { + this.endpoints = endpoints; + return this; + } + + /** + * Active key first. The first key is created on first issue. + * + * @param keys the value + * @return this builder + */ + public Builder keys(List keys) { + this.keys = Utils.mutableList(keys); + return this; + } + + /** + * Adds an item to {@code keys}. + * + * @param item the item + * @return this builder + */ + public Builder addKeysItem(LicenseSigningKey item) { + if (this.keys == null) { + this.keys = new ArrayList<>(); + } + this.keys.add(item); + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code LicenseSigningKeysResponse}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public LicenseSigningKeysResponse build() { + Utils.checkRequired(endpoints, "endpoints"); + Utils.checkRequired(keys, "keys"); + return new LicenseSigningKeysResponse(this); + } + } + + /** + * Parse {@code json} as {@code LicenseSigningKeysResponse}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static LicenseSigningKeysResponse fromJson(String json) { + return Utils.parse(json, LicenseSigningKeysResponse.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/LicenseStatus.java b/src/main/java/com/meteroid/models/LicenseStatus.java new file mode 100644 index 0000000..3d26809 --- /dev/null +++ b/src/main/java/com/meteroid/models/LicenseStatus.java @@ -0,0 +1,135 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.meteroid.internal.Utils.ToQueryParam; + +import java.util.Map; +import java.util.Objects; + +/** + * Values this version of the SDK does not know are kept, and sent back unchanged: {@link #value()} + * is an enum to switch on, {@code _UNKNOWN} for them, and {@link #known()} throws on them. + */ +public final class LicenseStatus implements ToQueryParam { + /** The value {@code "PENDING"}. */ + public static final LicenseStatus PENDING = new LicenseStatus("PENDING", Value.PENDING); + + /** The value {@code "ACTIVE"}. */ + public static final LicenseStatus ACTIVE = new LicenseStatus("ACTIVE", Value.ACTIVE); + + /** The value {@code "REVOKED"}. */ + public static final LicenseStatus REVOKED = new LicenseStatus("REVOKED", Value.REVOKED); + + private static final Map constants = + Map.ofEntries( + Map.entry("PENDING", PENDING), + Map.entry("ACTIVE", ACTIVE), + Map.entry("REVOKED", REVOKED)); + + private final String value; + private final Value variant; + + private LicenseStatus(String value, Value variant) { + this.value = value; + this.variant = variant; + } + + /** + * The constant for {@code value}, or an unknown LicenseStatus holding it. + * + * @param value the value + * @return the constant + */ + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static LicenseStatus of(String value) { + LicenseStatus constant = constants.get(Objects.requireNonNull(value, "value")); + return constant != null ? constant : new LicenseStatus(value, Value._UNKNOWN); + } + + /** + * The value as sent. + * + * @return the value + */ + @JsonValue + public String asString() { + return value; + } + + /** + * Whether this version of the SDK knows the value. + * + * @return whether it is known + */ + public boolean isKnown() { + return variant != Value._UNKNOWN; + } + + /** + * The value as an enum to switch on, unknown values included. + * + * @return the enum, {@code _UNKNOWN} when unknown + */ + public Value value() { + return variant; + } + + /** + * The value as an enum of the known values only. + * + * @return the enum + * @throws com.meteroid.exceptions.InvalidDataException when this version of the SDK does not + * know the value + */ + public Known known() { + if (!isKnown()) { + throw new com.meteroid.exceptions.InvalidDataException( + "unknown LicenseStatus: " + value); + } + return Known.valueOf(variant.name()); + } + + @Override + public String toQueryParam() { + return String.valueOf(value); + } + + @Override + public boolean equals(Object o) { + return o instanceof LicenseStatus && Objects.equals(value, ((LicenseStatus) o).value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + /** The values this version of the SDK knows. */ + public enum Known { + /** The {@code PENDING} constant. */ + PENDING, + /** The {@code ACTIVE} constant. */ + ACTIVE, + /** The {@code REVOKED} constant. */ + REVOKED + } + + /** The values this version of the SDK knows, and {@code _UNKNOWN} for the others. */ + public enum Value { + /** The {@code PENDING} constant. */ + PENDING, + /** The {@code ACTIVE} constant. */ + ACTIVE, + /** The {@code REVOKED} constant. */ + REVOKED, + /** A value this version of the SDK does not know. */ + _UNKNOWN + } +} diff --git a/src/main/java/com/meteroid/models/LicensingEndpoints.java b/src/main/java/com/meteroid/models/LicensingEndpoints.java new file mode 100644 index 0000000..30dcf2d --- /dev/null +++ b/src/main/java/com/meteroid/models/LicensingEndpoints.java @@ -0,0 +1,293 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * The public endpoints your installations talk to. + * + *

Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class LicensingEndpoints { + @JsonProperty("activate_url") + private String activateUrl; + + @JsonProperty("events_url") + private String eventsUrl; + + @JsonProperty("jwks_url") + private String jwksUrl; + + @JsonProperty("refresh_url") + private String refreshUrl; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private LicensingEndpoints() {} + + private LicensingEndpoints(Builder builder) { + this.activateUrl = builder.activateUrl; + this.eventsUrl = builder.eventsUrl; + this.jwksUrl = builder.jwksUrl; + this.refreshUrl = builder.refreshUrl; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code LicensingEndpoints}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.activateUrl = activateUrl; + builder.eventsUrl = eventsUrl; + builder.jwksUrl = jwksUrl; + builder.refreshUrl = refreshUrl; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The {@code activate_url} property. + * + * @return the value, never null + */ + public String activateUrl() { + return Utils.required(activateUrl, "activate_url"); + } + + /** + * The {@code events_url} property. + * + * @return the value, never null + */ + public String eventsUrl() { + return Utils.required(eventsUrl, "events_url"); + } + + /** + * The {@code jwks_url} property. + * + * @return the value, never null + */ + public String jwksUrl() { + return Utils.required(jwksUrl, "jwks_url"); + } + + /** + * The {@code refresh_url} property. + * + * @return the value, never null + */ + public String refreshUrl() { + return Utils.required(refreshUrl, "refresh_url"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LicensingEndpoints that = (LicensingEndpoints) o; + return Objects.equals(activateUrl, that.activateUrl) + && Objects.equals(eventsUrl, that.eventsUrl) + && Objects.equals(jwksUrl, that.jwksUrl) + && Objects.equals(refreshUrl, that.refreshUrl) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(activateUrl, eventsUrl, jwksUrl, refreshUrl, additionalProperties); + } + + @Override + public String toString() { + return "LicensingEndpoints{" + + "activateUrl=" + + activateUrl + + ", eventsUrl=" + + eventsUrl + + ", jwksUrl=" + + jwksUrl + + ", refreshUrl=" + + refreshUrl + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link LicensingEndpoints}. */ + public static final class Builder { + private String activateUrl; + private String eventsUrl; + private String jwksUrl; + private String refreshUrl; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The {@code activate_url} property. + * + * @param activateUrl the value + * @return this builder + */ + public Builder activateUrl(String activateUrl) { + this.activateUrl = activateUrl; + return this; + } + + /** + * The {@code events_url} property. + * + * @param eventsUrl the value + * @return this builder + */ + public Builder eventsUrl(String eventsUrl) { + this.eventsUrl = eventsUrl; + return this; + } + + /** + * The {@code jwks_url} property. + * + * @param jwksUrl the value + * @return this builder + */ + public Builder jwksUrl(String jwksUrl) { + this.jwksUrl = jwksUrl; + return this; + } + + /** + * The {@code refresh_url} property. + * + * @param refreshUrl the value + * @return this builder + */ + public Builder refreshUrl(String refreshUrl) { + this.refreshUrl = refreshUrl; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code LicensingEndpoints}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public LicensingEndpoints build() { + Utils.checkRequired(activateUrl, "activate_url"); + Utils.checkRequired(eventsUrl, "events_url"); + Utils.checkRequired(jwksUrl, "jwks_url"); + Utils.checkRequired(refreshUrl, "refresh_url"); + return new LicensingEndpoints(this); + } + } + + /** + * Parse {@code json} as {@code LicensingEndpoints}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static LicensingEndpoints fromJson(String json) { + return Utils.parse(json, LicensingEndpoints.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/OfflineLicense.java b/src/main/java/com/meteroid/models/OfflineLicense.java new file mode 100644 index 0000000..c24484b --- /dev/null +++ b/src/main/java/com/meteroid/models/OfflineLicense.java @@ -0,0 +1,199 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class OfflineLicense { + @JsonProperty("license") + private String license; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private OfflineLicense() {} + + private OfflineLicense(Builder builder) { + this.license = builder.license; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code OfflineLicense}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.license = license; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * The signed license (a JWT) to install in the air-gapped installation. + * + * @return the value, never null + */ + public String license() { + return Utils.required(license, "license"); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OfflineLicense that = (OfflineLicense) o; + return Objects.equals(license, that.license) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(license, additionalProperties); + } + + @Override + public String toString() { + return "OfflineLicense{" + + "license=" + + license + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link OfflineLicense}. */ + public static final class Builder { + private String license; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * The signed license (a JWT) to install in the air-gapped installation. + * + * @param license the value + * @return this builder + */ + public Builder license(String license) { + this.license = license; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code OfflineLicense}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public OfflineLicense build() { + Utils.checkRequired(license, "license"); + return new OfflineLicense(this); + } + } + + /** + * Parse {@code json} as {@code OfflineLicense}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static OfflineLicense fromJson(String json) { + return Utils.parse(json, OfflineLicense.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/main/java/com/meteroid/models/Plan.java b/src/main/java/com/meteroid/models/Plan.java index 19888ad..0939b0c 100644 --- a/src/main/java/com/meteroid/models/Plan.java +++ b/src/main/java/com/meteroid/models/Plan.java @@ -56,6 +56,9 @@ public final class Plan { @JsonProperty("id") private String id; + @JsonProperty("issues_license") + private Boolean issuesLicense; + @JsonProperty("minimum_commitment") @JsonInclude(JsonInclude.Include.NON_EMPTY) private JsonField minimumCommitment = JsonField.missing(); @@ -112,6 +115,7 @@ private Plan(Builder builder) { this.description = builder.description; this.entitlements = Utils.copyList(builder.entitlements); this.id = builder.id; + this.issuesLicense = builder.issuesLicense; this.minimumCommitment = builder.minimumCommitment; this.name = builder.name; this.netTerms = builder.netTerms; @@ -152,6 +156,7 @@ public Builder toBuilder() { builder.description = description; builder.entitlements = Utils.mutableList(entitlements); builder.id = id; + builder.issuesLicense = issuesLicense; builder.minimumCommitment = minimumCommitment; builder.name = name; builder.netTerms = netTerms; @@ -241,6 +246,15 @@ public String id() { return Utils.required(id, "id"); } + /** + * Subscriptions to this plan are issued a software license automatically. + * + * @return the value, empty when unset + */ + public Optional issuesLicense() { + return Optional.ofNullable(issuesLicense); + } + /** * The {@code minimum_commitment} property. * @@ -397,6 +411,7 @@ public boolean equals(Object o) { && Objects.equals(description, that.description) && Objects.equals(entitlements, that.entitlements) && Objects.equals(id, that.id) + && Objects.equals(issuesLicense, that.issuesLicense) && Objects.equals(minimumCommitment, that.minimumCommitment) && Objects.equals(name, that.name) && Objects.equals(netTerms, that.netTerms) @@ -424,6 +439,7 @@ public int hashCode() { description, entitlements, id, + issuesLicense, minimumCommitment, name, netTerms, @@ -459,6 +475,8 @@ public String toString() { + entitlements + ", id=" + id + + ", issuesLicense=" + + issuesLicense + ", minimumCommitment=" + minimumCommitment + ", name=" @@ -500,6 +518,7 @@ public static final class Builder { private JsonField description = JsonField.missing(); private List entitlements; private String id; + private Boolean issuesLicense; private JsonField minimumCommitment = JsonField.missing(); private String name; private Integer netTerms; @@ -619,6 +638,17 @@ public Builder id(String id) { return this; } + /** + * Subscriptions to this plan are issued a software license automatically. + * + * @param issuesLicense the value + * @return this builder + */ + public Builder issuesLicense(Boolean issuesLicense) { + this.issuesLicense = issuesLicense; + return this; + } + /** * The {@code minimum_commitment} property. * diff --git a/src/main/java/com/meteroid/models/RevokeLicenseRequest.java b/src/main/java/com/meteroid/models/RevokeLicenseRequest.java new file mode 100644 index 0000000..31d9cc6 --- /dev/null +++ b/src/main/java/com/meteroid/models/RevokeLicenseRequest.java @@ -0,0 +1,201 @@ +// This file is @generated +package com.meteroid.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import com.meteroid.internal.Utils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonAutoDetect( + getterVisibility = Visibility.NONE, + isGetterVisibility = Visibility.NONE, + setterVisibility = Visibility.NONE) +public final class RevokeLicenseRequest { + @JsonProperty("immediately") + private Boolean immediately; + + private final Map additionalProperties = new LinkedHashMap<>(); + + private RevokeLicenseRequest() {} + + private RevokeLicenseRequest(Builder builder) { + this.immediately = builder.immediately; + this.additionalProperties.putAll(builder.additionalProperties); + } + + /** + * A builder of {@code RevokeLicenseRequest}. + * + * @return a new builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A builder starting from this value. + * + * @return a new builder + */ + public Builder toBuilder() { + Builder builder = new Builder(); + builder.immediately = immediately; + builder.additionalProperties.putAll(additionalProperties); + return builder; + } + + /** + * Stop at once: the installation drops its license on its next refresh. Otherwise the license + * keeps working until it expires, and is not renewed. + * + * @return the value, empty when unset + */ + public Optional immediately() { + return Optional.ofNullable(immediately); + } + + /** + * Properties this version of the SDK does not know, kept as received and sent back. + * + * @return the properties by name, unmodifiable + */ + public Map additionalProperties() { + return Collections.unmodifiableMap(additionalProperties); + } + + @JsonAnyGetter + private Map anyProperties() { + return additionalProperties; + } + + @JsonAnySetter + private void putAnyProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RevokeLicenseRequest that = (RevokeLicenseRequest) o; + return Objects.equals(immediately, that.immediately) + && Objects.equals(additionalProperties, that.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(immediately, additionalProperties); + } + + @Override + public String toString() { + return "RevokeLicenseRequest{" + + "immediately=" + + immediately + + ", additionalProperties=" + + additionalProperties + + "}"; + } + + /** Builds {@link RevokeLicenseRequest}. */ + public static final class Builder { + private Boolean immediately; + private final Map additionalProperties = new LinkedHashMap<>(); + + private Builder() {} + + /** + * Stop at once: the installation drops its license on its next refresh. Otherwise the + * license keeps working until it expires, and is not renewed. + * + * @param immediately the value + * @return this builder + */ + public Builder immediately(Boolean immediately) { + this.immediately = immediately; + return this; + } + + /** + * A property the SDK does not know, sent along. + * + * @param name the property name + * @param value the JSON value + * @return this builder + */ + public Builder putAdditionalProperty(String name, JsonNode value) { + additionalProperties.put(name, value); + return this; + } + + /** + * Properties the SDK does not know, sent along. + * + * @param additionalProperties the properties by name + * @return this builder + */ + public Builder putAllAdditionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + + /** + * Leaves out a property the SDK does not know. + * + * @param name the property name + * @return this builder + */ + public Builder removeAdditionalProperty(String name) { + additionalProperties.remove(name); + return this; + } + + /** + * The {@code RevokeLicenseRequest}. + * + * @return the immutable value + * @throws IllegalStateException when a required property is not set + */ + public RevokeLicenseRequest build() { + return new RevokeLicenseRequest(this); + } + } + + /** + * Parse {@code json} as {@code RevokeLicenseRequest}. + * + * @param json the JSON text + * @return the value + * @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape + */ + public static RevokeLicenseRequest fromJson(String json) { + return Utils.parse(json, RevokeLicenseRequest.class); + } + + /** + * This value as JSON. + * + * @return the JSON text + */ + public String toJson() { + return Utils.json(this); + } +} diff --git a/src/test/java/com/meteroid/api/LicensesTest.java b/src/test/java/com/meteroid/api/LicensesTest.java new file mode 100644 index 0000000..11e08a1 --- /dev/null +++ b/src/test/java/com/meteroid/api/LicensesTest.java @@ -0,0 +1,96 @@ +// this file is @generated +package com.meteroid.api; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +class LicensesTest { + + @Test + void list() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"data\":[{\"auto_issued\":false,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"customer_id\":\"customer_id_2\",\"customer_name\":\"sample\",\"has_activation_code\":false,\"id\":\"license_id_0\",\"offline\":false,\"revoked_immediately\":false,\"status\":\"REVOKED\",\"validity_days\":-123456789}]}"); + mock.client.licenses().list(); + assertEquals(List.of("GET /api/v1/licenses"), mock.requests); + } + + @Test + void create() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"license\":{\"auto_issued\":false,\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"customer_id\":\"customer_id_37\",\"customer_name\":\"sample\",\"has_activation_code\":true,\"id\":\"license_id_40\",\"offline\":true,\"revoked_immediately\":true,\"status\":\"PENDING\",\"validity_days\":123456789}}"); + mock.client + .licenses() + .create( + PerseidMock.decode( + com.meteroid.models.IssueLicenseRequest.class, + "{\"customer_id\":\"sample\"}")); + assertEquals(List.of("POST /api/v1/licenses"), mock.requests); + } + + @Test + void retrieve() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"auto_issued\":false,\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"customer_id\":\"customer_id_79\",\"customer_name\":\"sample\",\"has_activation_code\":false,\"id\":\"license_id_90\",\"offline\":false,\"revoked_immediately\":true,\"status\":\"PENDING\",\"validity_days\":-123456789}"); + mock.client.licenses().retrieve("license_id"); + assertEquals(List.of("GET /api/v1/licenses/license_id"), mock.requests); + } + + @Test + void retrieveActivationCode() throws Exception { + PerseidMock mock = + new PerseidMock(200, "application/json", "{\"activation_code\":\"sample\"}"); + mock.client.licenses().retrieveActivationCode("license_id"); + assertEquals(List.of("GET /api/v1/licenses/license_id/activation-code"), mock.requests); + } + + @Test + void offline() throws Exception { + PerseidMock mock = new PerseidMock(200, "application/json", "{\"license\":\"sample\"}"); + mock.client + .licenses() + .offline( + "license_id", + PerseidMock.decode( + com.meteroid.models.IssueOfflineLicenseRequest.class, + "{\"valid_days\":123456789}")); + assertEquals(List.of("POST /api/v1/licenses/license_id/offline"), mock.requests); + } + + @Test + void revoke() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"auto_issued\":false,\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"customer_id\":\"customer_id_79\",\"customer_name\":\"sample\",\"has_activation_code\":false,\"id\":\"license_id_90\",\"offline\":false,\"revoked_immediately\":true,\"status\":\"PENDING\",\"validity_days\":-123456789}"); + mock.client + .licenses() + .revoke( + "license_id", + PerseidMock.decode(com.meteroid.models.RevokeLicenseRequest.class, "{}")); + assertEquals(List.of("POST /api/v1/licenses/license_id/revoke"), mock.requests); + } + + @Test + void listLicensingSigningKeys() throws Exception { + PerseidMock mock = + new PerseidMock( + 200, + "application/json", + "{\"endpoints\":{\"activate_url\":\"sample\",\"events_url\":\"sample\",\"jwks_url\":\"sample\",\"refresh_url\":\"sample\"},\"keys\":[{\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"kid\":\"sample\",\"public_key_pem\":\"sample\",\"status\":\"ACTIVE\"}]}"); + mock.client.licenses().listLicensingSigningKeys(); + assertEquals(List.of("GET /api/v1/licensing/signing-keys"), mock.requests); + } +} diff --git a/src/test/java/com/meteroid/api/PlansTest.java b/src/test/java/com/meteroid/api/PlansTest.java index 3e234c8..19e3a6e 100644 --- a/src/test/java/com/meteroid/api/PlansTest.java +++ b/src/test/java/com/meteroid/api/PlansTest.java @@ -45,7 +45,7 @@ void list() throws Exception { new PerseidMock( 200, "application/json", - "{\"data\":[{\"available_parameters\":{},\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"TMT\",\"id\":\"plan_id_25\",\"name\":\"sample\",\"net_terms\":-2147483648,\"plan_type\":\"CUSTOM\",\"price_components\":[{\"id\":\"price_component_id_8\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_2\",\"name\":\"sample\"},\"status\":\"DRAFT\",\"tax_inclusive\":false,\"version\":123456789,\"version_id\":\"plan_version_id_3\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); + "{\"data\":[{\"available_parameters\":{},\"created_at\":\"2024-03-15T10:30:45.123+02:00\",\"currency\":\"TMT\",\"id\":\"plan_id_25\",\"name\":\"sample\",\"net_terms\":-2147483648,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_2\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_19\",\"name\":\"sample\"},\"status\":\"ARCHIVED\",\"tax_inclusive\":false,\"version\":-2147483648,\"version_id\":\"plan_version_id_67\"}],\"pagination_meta\":{\"page\":-123456789,\"per_page\":-123456789,\"total_items\":-9007199254740993,\"total_pages\":123456789}}"); mock.client.plans().list(); assertEquals(List.of("GET /api/v1/plans"), mock.requests); } @@ -56,7 +56,7 @@ void create() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_40\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_5\",\"name\":\"sample\"},\"status\":\"INACTIVE\",\"tax_inclusive\":true,\"version\":-2147483648,\"version_id\":\"plan_version_id_81\"}"); mock.client .plans() .create( @@ -72,7 +72,7 @@ void retrieve() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_40\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_5\",\"name\":\"sample\"},\"status\":\"INACTIVE\",\"tax_inclusive\":true,\"version\":-2147483648,\"version_id\":\"plan_version_id_81\"}"); mock.client.plans().retrieve("plan_id"); assertEquals(List.of("GET /api/v1/plans/plan_id"), mock.requests); } @@ -83,7 +83,7 @@ void replace() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_40\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_5\",\"name\":\"sample\"},\"status\":\"INACTIVE\",\"tax_inclusive\":true,\"version\":-2147483648,\"version_id\":\"plan_version_id_81\"}"); mock.client .plans() .replace( @@ -100,7 +100,7 @@ void update() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_40\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_5\",\"name\":\"sample\"},\"status\":\"INACTIVE\",\"tax_inclusive\":true,\"version\":-2147483648,\"version_id\":\"plan_version_id_81\"}"); mock.client .plans() .update( @@ -122,7 +122,7 @@ void publish() throws Exception { new PerseidMock( 200, "application/json", - "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":-123456789,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_88\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_15\",\"name\":\"sample\"},\"status\":\"ACTIVE\",\"tax_inclusive\":true,\"version\":123456789,\"version_id\":\"plan_version_id_79\"}"); + "{\"available_parameters\":{},\"created_at\":\"2023-12-31T23:59:59.999-05:30\",\"currency\":\"MMK\",\"id\":\"plan_id_40\",\"name\":\"sample\",\"net_terms\":2147483647,\"plan_type\":\"STANDARD\",\"price_components\":[{\"id\":\"price_component_id_40\",\"name\":\"sample\"}],\"product_family\":{\"id\":\"product_family_id_5\",\"name\":\"sample\"},\"status\":\"INACTIVE\",\"tax_inclusive\":true,\"version\":-2147483648,\"version_id\":\"plan_version_id_81\"}"); mock.client.plans().publish("plan_id"); assertEquals(List.of("POST /api/v1/plans/plan_id/publish"), mock.requests); }