diff --git a/src/main/java/com/ngrok/definitions/EndpointTrafficPolicy.java b/src/main/java/com/ngrok/definitions/EndpointTrafficPolicy.java new file mode 100644 index 0000000..fb150e4 --- /dev/null +++ b/src/main/java/com/ngrok/definitions/EndpointTrafficPolicy.java @@ -0,0 +1,171 @@ +/* Code generated for API Clients. DO NOT EDIT. */ + +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link EndpointTrafficPolicy} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EndpointTrafficPolicy { + /** + * Builder class for {@link EndpointTrafficPolicy}. + */ + public static class Builder { + private Optional enabled = Optional.empty(); + private Optional value = Optional.empty(); + + private Builder( + ) { + } + + /** + * true if the module will be applied to traffic, false + * to disable. default true if unspecified + * + * @param enabled the value of the enabled parameter as a {@link boolean} + * @return this builder instance + */ + public Builder enabled(final boolean enabled) { + this.enabled = Optional.of(Objects.requireNonNull(enabled, "enabled is required")); + return this; + } + + /** + * true if the module will be applied to traffic, false + * to disable. default true if unspecified + * + * @param enabled the value of the enabled parameter as a {@link boolean}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder enabled(final Optional enabled) { + this.enabled = Objects.requireNonNull(enabled, "enabled is required"); + return this; + } + + /** + * the traffic policy that should be applied to the traffic on your endpoint. + * + * @param value the value of the value parameter as a {@link String} + * @return this builder instance + */ + public Builder value(final String value) { + this.value = Optional.of(Objects.requireNonNull(value, "value is required")); + return this; + } + + /** + * the traffic policy that should be applied to the traffic on your endpoint. + * + * @param value the value of the value parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder value(final Optional value) { + this.value = Objects.requireNonNull(value, "value is required"); + return this; + } + + /** + * Constructs the {@link EndpointTrafficPolicy} instance. + * + * @return a new {@link EndpointTrafficPolicy} + */ + public EndpointTrafficPolicy build() { + return new EndpointTrafficPolicy( + this.enabled, + this.value.orElse("") + ); + } + } + + /** + * Creates a new builder for the {@link EndpointTrafficPolicy} type. + * + * @return a new {@link Builder} + */ + public static Builder newBuilder( + ) { + return new Builder ( + ); + } + + @JsonProperty("enabled") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional enabled; + @JsonProperty("value") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String value; + + /** + * Creates a new instance of {@link EndpointTrafficPolicy}. + * + * @param enabled true if the module will be applied to traffic, false to disable. default true if unspecified + * @param value the traffic policy that should be applied to the traffic on your endpoint. + */ + @JsonCreator + private EndpointTrafficPolicy( + @JsonProperty("enabled") final Optional enabled, + @JsonProperty("value") final String value + ) { + this.enabled = enabled != null ? enabled : Optional.empty(); + this.value = Objects.requireNonNull(value, "value is required"); + } + + /** + * true if the module will be applied to traffic, false + * to disable. default true if unspecified + * + * @return the value of the property as a {@link boolean} wrapped in an {@link Optional} + */ + public Optional getEnabled() { + return this.enabled; + } + + /** + * the traffic policy that should be applied to the traffic on your endpoint. + * + * @return the value of the property as a {@link String} + */ + public String getValue() { + return this.value; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final EndpointTrafficPolicy other = (EndpointTrafficPolicy) o; + return + this.enabled.equals(other.enabled)&& + this.value.equals(other.value); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.enabled, + this.value + ); + } + + @Override + public String toString() { + return "EndpointTrafficPolicy{" + + "enabled='" + this.enabled.map(Object::toString).orElse("(null)") + + "', value='" + this.value + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/EventTarget.java b/src/main/java/com/ngrok/definitions/EventTarget.java index 0141473..e9c13fa 100644 --- a/src/main/java/com/ngrok/definitions/EventTarget.java +++ b/src/main/java/com/ngrok/definitions/EventTarget.java @@ -23,6 +23,7 @@ public class EventTarget { private Optional kinesis = Optional.empty(); private Optional cloudwatchLogs = Optional.empty(); private Optional datadog = Optional.empty(); + private Optional azureLogsIngestion = Optional.empty(); private Builder( ) { @@ -116,6 +117,28 @@ public class EventTarget { return this; } + /** + * Sets the azure_logs_ingestion property + * + * @param azureLogsIngestion the value of the azure_logs_ingestion parameter as a {@link EventTargetAzureLogsIngestion} + * @return this builder instance + */ + public Builder azureLogsIngestion(final EventTargetAzureLogsIngestion azureLogsIngestion) { + this.azureLogsIngestion = Optional.of(Objects.requireNonNull(azureLogsIngestion, "azureLogsIngestion is required")); + return this; + } + + /** + * Sets the azure_logs_ingestion property + * + * @param azureLogsIngestion the value of the azure_logs_ingestion parameter as a {@link EventTargetAzureLogsIngestion}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder azureLogsIngestion(final Optional azureLogsIngestion) { + this.azureLogsIngestion = Objects.requireNonNull(azureLogsIngestion, "azureLogsIngestion is required"); + return this; + } + /** * Constructs the {@link EventTarget} instance. * @@ -126,7 +149,8 @@ public class EventTarget { this.firehose, this.kinesis, this.cloudwatchLogs, - this.datadog + this.datadog, + this.azureLogsIngestion ); } } @@ -154,6 +178,9 @@ public class EventTarget { @JsonProperty("datadog") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final Optional datadog; + @JsonProperty("azure_logs_ingestion") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional azureLogsIngestion; /** * Creates a new instance of {@link EventTarget}. @@ -162,18 +189,21 @@ public class EventTarget { * @param kinesis Configuration used to send events to Amazon Kinesis. * @param cloudwatchLogs Configuration used to send events to Amazon CloudWatch Logs. * @param datadog Configuration used to send events to Datadog. + * @param azureLogsIngestion the value of the azure_logs_ingestion parameter as a {@link EventTargetAzureLogsIngestion} */ @JsonCreator private EventTarget( @JsonProperty("firehose") final Optional firehose, @JsonProperty("kinesis") final Optional kinesis, @JsonProperty("cloudwatch_logs") final Optional cloudwatchLogs, - @JsonProperty("datadog") final Optional datadog + @JsonProperty("datadog") final Optional datadog, + @JsonProperty("azure_logs_ingestion") final Optional azureLogsIngestion ) { this.firehose = firehose != null ? firehose : Optional.empty(); this.kinesis = kinesis != null ? kinesis : Optional.empty(); this.cloudwatchLogs = cloudwatchLogs != null ? cloudwatchLogs : Optional.empty(); this.datadog = datadog != null ? datadog : Optional.empty(); + this.azureLogsIngestion = azureLogsIngestion != null ? azureLogsIngestion : Optional.empty(); } /** @@ -212,6 +242,15 @@ public class EventTarget { return this.datadog; } + /** + * Fetches the value of the azureLogsIngestion property. + * + * @return the value of the property as a {@link EventTargetAzureLogsIngestion} wrapped in an {@link Optional} + */ + public Optional getAzureLogsIngestion() { + return this.azureLogsIngestion; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -226,7 +265,8 @@ public class EventTarget { this.firehose.equals(other.firehose)&& this.kinesis.equals(other.kinesis)&& this.cloudwatchLogs.equals(other.cloudwatchLogs)&& - this.datadog.equals(other.datadog); + this.datadog.equals(other.datadog)&& + this.azureLogsIngestion.equals(other.azureLogsIngestion); } @@ -236,7 +276,8 @@ public class EventTarget { this.firehose, this.kinesis, this.cloudwatchLogs, - this.datadog + this.datadog, + this.azureLogsIngestion ); } @@ -247,6 +288,7 @@ public class EventTarget { "', kinesis='" + this.kinesis.map(Object::toString).orElse("(null)") + "', cloudwatchLogs='" + this.cloudwatchLogs.map(Object::toString).orElse("(null)") + "', datadog='" + this.datadog.map(Object::toString).orElse("(null)") + + "', azureLogsIngestion='" + this.azureLogsIngestion.map(Object::toString).orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/definitions/EventTargetAzureLogsIngestion.java b/src/main/java/com/ngrok/definitions/EventTargetAzureLogsIngestion.java new file mode 100644 index 0000000..51b8c2b --- /dev/null +++ b/src/main/java/com/ngrok/definitions/EventTargetAzureLogsIngestion.java @@ -0,0 +1,234 @@ +/* Code generated for API Clients. DO NOT EDIT. */ + +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link EventTargetAzureLogsIngestion} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EventTargetAzureLogsIngestion { + /** + * Builder class for {@link EventTargetAzureLogsIngestion}. + */ + public static class Builder { + private final String tenantId; + private final String clientId; + private final String clientSecret; + private final String logsIngestionUri; + private final String dataCollectionRuleId; + private final String dataCollectionStreamName; + + private Builder( + final String tenantId, + final String clientId, + final String clientSecret, + final String logsIngestionUri, + final String dataCollectionRuleId, + final String dataCollectionStreamName + ) { + this.tenantId = Objects.requireNonNull(tenantId, "tenantId is required"); + this.clientId = Objects.requireNonNull(clientId, "clientId is required"); + this.clientSecret = Objects.requireNonNull(clientSecret, "clientSecret is required"); + this.logsIngestionUri = Objects.requireNonNull(logsIngestionUri, "logsIngestionUri is required"); + this.dataCollectionRuleId = Objects.requireNonNull(dataCollectionRuleId, "dataCollectionRuleId is required"); + this.dataCollectionStreamName = Objects.requireNonNull(dataCollectionStreamName, "dataCollectionStreamName is required"); + } + + /** + * Constructs the {@link EventTargetAzureLogsIngestion} instance. + * + * @return a new {@link EventTargetAzureLogsIngestion} + */ + public EventTargetAzureLogsIngestion build() { + return new EventTargetAzureLogsIngestion( + this.tenantId, + this.clientId, + this.clientSecret, + this.logsIngestionUri, + this.dataCollectionRuleId, + this.dataCollectionStreamName + ); + } + } + + /** + * Creates a new builder for the {@link EventTargetAzureLogsIngestion} type. + * + * @param tenantId Tenant ID for the Azure account + * @param clientId Client ID for the application client + * @param clientSecret Client Secret for the application client + * @param logsIngestionUri Data collection endpoint logs ingestion URI + * @param dataCollectionRuleId Data collection rule immutable ID + * @param dataCollectionStreamName Data collection stream name to use as destination, located instide the DCR + * @return a new {@link Builder} + */ + public static Builder newBuilder( + final String tenantId, + final String clientId, + final String clientSecret, + final String logsIngestionUri, + final String dataCollectionRuleId, + final String dataCollectionStreamName + ) { + return new Builder ( + tenantId, + clientId, + clientSecret, + logsIngestionUri, + dataCollectionRuleId, + dataCollectionStreamName + ); + } + + @JsonProperty("tenant_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String tenantId; + @JsonProperty("client_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String clientId; + @JsonProperty("client_secret") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String clientSecret; + @JsonProperty("logs_ingestion_uri") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String logsIngestionUri; + @JsonProperty("data_collection_rule_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String dataCollectionRuleId; + @JsonProperty("data_collection_stream_name") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String dataCollectionStreamName; + + /** + * Creates a new instance of {@link EventTargetAzureLogsIngestion}. + * + * @param tenantId Tenant ID for the Azure account + * @param clientId Client ID for the application client + * @param clientSecret Client Secret for the application client + * @param logsIngestionUri Data collection endpoint logs ingestion URI + * @param dataCollectionRuleId Data collection rule immutable ID + * @param dataCollectionStreamName Data collection stream name to use as destination, located instide the DCR + */ + @JsonCreator + private EventTargetAzureLogsIngestion( + @JsonProperty("tenant_id") final String tenantId, + @JsonProperty("client_id") final String clientId, + @JsonProperty("client_secret") final String clientSecret, + @JsonProperty("logs_ingestion_uri") final String logsIngestionUri, + @JsonProperty("data_collection_rule_id") final String dataCollectionRuleId, + @JsonProperty("data_collection_stream_name") final String dataCollectionStreamName + ) { + this.tenantId = Objects.requireNonNull(tenantId, "tenantId is required"); + this.clientId = Objects.requireNonNull(clientId, "clientId is required"); + this.clientSecret = Objects.requireNonNull(clientSecret, "clientSecret is required"); + this.logsIngestionUri = Objects.requireNonNull(logsIngestionUri, "logsIngestionUri is required"); + this.dataCollectionRuleId = Objects.requireNonNull(dataCollectionRuleId, "dataCollectionRuleId is required"); + this.dataCollectionStreamName = Objects.requireNonNull(dataCollectionStreamName, "dataCollectionStreamName is required"); + } + + /** + * Tenant ID for the Azure account + * + * @return the value of the property as a {@link String} + */ + public String getTenantId() { + return this.tenantId; + } + + /** + * Client ID for the application client + * + * @return the value of the property as a {@link String} + */ + public String getClientId() { + return this.clientId; + } + + /** + * Client Secret for the application client + * + * @return the value of the property as a {@link String} + */ + public String getClientSecret() { + return this.clientSecret; + } + + /** + * Data collection endpoint logs ingestion URI + * + * @return the value of the property as a {@link String} + */ + public String getLogsIngestionUri() { + return this.logsIngestionUri; + } + + /** + * Data collection rule immutable ID + * + * @return the value of the property as a {@link String} + */ + public String getDataCollectionRuleId() { + return this.dataCollectionRuleId; + } + + /** + * Data collection stream name to use as destination, located instide the DCR + * + * @return the value of the property as a {@link String} + */ + public String getDataCollectionStreamName() { + return this.dataCollectionStreamName; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final EventTargetAzureLogsIngestion other = (EventTargetAzureLogsIngestion) o; + return + this.tenantId.equals(other.tenantId)&& + this.clientId.equals(other.clientId)&& + this.clientSecret.equals(other.clientSecret)&& + this.logsIngestionUri.equals(other.logsIngestionUri)&& + this.dataCollectionRuleId.equals(other.dataCollectionRuleId)&& + this.dataCollectionStreamName.equals(other.dataCollectionStreamName); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.tenantId, + this.clientId, + this.clientSecret, + this.logsIngestionUri, + this.dataCollectionRuleId, + this.dataCollectionStreamName + ); + } + + @Override + public String toString() { + return "EventTargetAzureLogsIngestion{" + + "tenantId='" + this.tenantId + + "', clientId='" + this.clientId + + "', clientSecret='" + this.clientSecret + + "', logsIngestionUri='" + this.logsIngestionUri + + "', dataCollectionRuleId='" + this.dataCollectionRuleId + + "', dataCollectionStreamName='" + this.dataCollectionStreamName + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/HttpsEdgeRoute.java b/src/main/java/com/ngrok/definitions/HttpsEdgeRoute.java index 32cb380..cd0e834 100644 --- a/src/main/java/com/ngrok/definitions/HttpsEdgeRoute.java +++ b/src/main/java/com/ngrok/definitions/HttpsEdgeRoute.java @@ -75,9 +75,9 @@ public class HttpsEdgeRoute { @JsonProperty("user_agent_filter") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final Optional userAgentFilter; - @JsonProperty("policy") + @JsonProperty("traffic_policy") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final Optional policy; + private final Optional trafficPolicy; /** * Creates a new instance of {@link HttpsEdgeRoute}. @@ -102,7 +102,7 @@ public class HttpsEdgeRoute { * @param oidc oidc module configuration or null * @param websocketTcpConverter websocket to tcp adapter configuration or null * @param userAgentFilter the value of the user_agent_filter parameter as a {@link EndpointUserAgentFilter} - * @param policy the traffic policy associated with this edge or null + * @param trafficPolicy the traffic policy associated with this edge or null */ @JsonCreator public HttpsEdgeRoute( @@ -126,7 +126,7 @@ public class HttpsEdgeRoute { @JsonProperty("oidc") final Optional oidc, @JsonProperty("websocket_tcp_converter") final Optional websocketTcpConverter, @JsonProperty("user_agent_filter") final Optional userAgentFilter, - @JsonProperty("policy") final Optional policy + @JsonProperty("traffic_policy") final Optional trafficPolicy ) { this.edgeId = Objects.requireNonNull(edgeId, "edgeId is required"); this.id = Objects.requireNonNull(id, "id is required"); @@ -148,7 +148,7 @@ public class HttpsEdgeRoute { this.oidc = oidc != null ? oidc : Optional.empty(); this.websocketTcpConverter = websocketTcpConverter != null ? websocketTcpConverter : Optional.empty(); this.userAgentFilter = userAgentFilter != null ? userAgentFilter : Optional.empty(); - this.policy = policy != null ? policy : Optional.empty(); + this.trafficPolicy = trafficPolicy != null ? trafficPolicy : Optional.empty(); } /** @@ -338,10 +338,10 @@ public class HttpsEdgeRoute { /** * the traffic policy associated with this edge or null * - * @return the value of the property as a {@link EndpointPolicy} wrapped in an {@link Optional} + * @return the value of the property as a {@link EndpointTrafficPolicy} wrapped in an {@link Optional} */ - public Optional getPolicy() { - return this.policy; + public Optional getTrafficPolicy() { + return this.trafficPolicy; } @Override @@ -375,7 +375,7 @@ public class HttpsEdgeRoute { this.oidc.equals(other.oidc)&& this.websocketTcpConverter.equals(other.websocketTcpConverter)&& this.userAgentFilter.equals(other.userAgentFilter)&& - this.policy.equals(other.policy); + this.trafficPolicy.equals(other.trafficPolicy); } @@ -402,7 +402,7 @@ public class HttpsEdgeRoute { this.oidc, this.websocketTcpConverter, this.userAgentFilter, - this.policy + this.trafficPolicy ); } @@ -429,7 +429,7 @@ public class HttpsEdgeRoute { "', oidc='" + this.oidc.map(Object::toString).orElse("(null)") + "', websocketTcpConverter='" + this.websocketTcpConverter.map(Object::toString).orElse("(null)") + "', userAgentFilter='" + this.userAgentFilter.map(Object::toString).orElse("(null)") + - "', policy='" + this.policy.map(Object::toString).orElse("(null)") + + "', trafficPolicy='" + this.trafficPolicy.map(Object::toString).orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/definitions/TcpEdge.java b/src/main/java/com/ngrok/definitions/TcpEdge.java index ab7ba0d..1948d5a 100644 --- a/src/main/java/com/ngrok/definitions/TcpEdge.java +++ b/src/main/java/com/ngrok/definitions/TcpEdge.java @@ -39,9 +39,9 @@ public class TcpEdge { @JsonProperty("ip_restriction") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final Optional ipRestriction; - @JsonProperty("policy") + @JsonProperty("traffic_policy") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final Optional policy; + private final Optional trafficPolicy; /** * Creates a new instance of {@link TcpEdge}. @@ -54,7 +54,7 @@ public class TcpEdge { * @param hostports hostports served by this edge * @param backend edge modules * @param ipRestriction the value of the ip_restriction parameter as a {@link EndpointIpPolicy} - * @param policy the traffic policy associated with this edge or null + * @param trafficPolicy the traffic policy associated with this edge or null */ @JsonCreator public TcpEdge( @@ -66,7 +66,7 @@ public class TcpEdge { @JsonProperty("hostports") final Optional> hostports, @JsonProperty("backend") final Optional backend, @JsonProperty("ip_restriction") final Optional ipRestriction, - @JsonProperty("policy") final Optional policy + @JsonProperty("traffic_policy") final Optional trafficPolicy ) { this.id = Objects.requireNonNull(id, "id is required"); this.description = description != null ? description : Optional.empty(); @@ -76,7 +76,7 @@ public class TcpEdge { this.hostports = hostports != null ? hostports : Optional.empty(); this.backend = backend != null ? backend : Optional.empty(); this.ipRestriction = ipRestriction != null ? ipRestriction : Optional.empty(); - this.policy = policy != null ? policy : Optional.empty(); + this.trafficPolicy = trafficPolicy != null ? trafficPolicy : Optional.empty(); } /** @@ -156,10 +156,10 @@ public class TcpEdge { /** * the traffic policy associated with this edge or null * - * @return the value of the property as a {@link EndpointPolicy} wrapped in an {@link Optional} + * @return the value of the property as a {@link EndpointTrafficPolicy} wrapped in an {@link Optional} */ - public Optional getPolicy() { - return this.policy; + public Optional getTrafficPolicy() { + return this.trafficPolicy; } @Override @@ -181,7 +181,7 @@ public class TcpEdge { this.hostports.equals(other.hostports)&& this.backend.equals(other.backend)&& this.ipRestriction.equals(other.ipRestriction)&& - this.policy.equals(other.policy); + this.trafficPolicy.equals(other.trafficPolicy); } @@ -196,7 +196,7 @@ public class TcpEdge { this.hostports, this.backend, this.ipRestriction, - this.policy + this.trafficPolicy ); } @@ -211,7 +211,7 @@ public class TcpEdge { "', hostports='" + this.hostports.map(Object::toString).orElse("(null)") + "', backend='" + this.backend.map(Object::toString).orElse("(null)") + "', ipRestriction='" + this.ipRestriction.map(Object::toString).orElse("(null)") + - "', policy='" + this.policy.map(Object::toString).orElse("(null)") + + "', trafficPolicy='" + this.trafficPolicy.map(Object::toString).orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/definitions/TlsEdge.java b/src/main/java/com/ngrok/definitions/TlsEdge.java index a19ef28..99c57c0 100644 --- a/src/main/java/com/ngrok/definitions/TlsEdge.java +++ b/src/main/java/com/ngrok/definitions/TlsEdge.java @@ -45,9 +45,9 @@ public class TlsEdge { @JsonProperty("tls_termination") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final Optional tlsTermination; - @JsonProperty("policy") + @JsonProperty("traffic_policy") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final Optional policy; + private final Optional trafficPolicy; /** * Creates a new instance of {@link TlsEdge}. @@ -62,7 +62,7 @@ public class TlsEdge { * @param ipRestriction the value of the ip_restriction parameter as a {@link EndpointIpPolicy} * @param mutualTls the value of the mutual_tls parameter as a {@link EndpointMutualTls} * @param tlsTermination the value of the tls_termination parameter as a {@link EndpointTlsTermination} - * @param policy the traffic policy associated with this edge or null + * @param trafficPolicy the traffic policy associated with this edge or null */ @JsonCreator public TlsEdge( @@ -76,7 +76,7 @@ public class TlsEdge { @JsonProperty("ip_restriction") final Optional ipRestriction, @JsonProperty("mutual_tls") final Optional mutualTls, @JsonProperty("tls_termination") final Optional tlsTermination, - @JsonProperty("policy") final Optional policy + @JsonProperty("traffic_policy") final Optional trafficPolicy ) { this.id = Objects.requireNonNull(id, "id is required"); this.description = description != null ? description : Optional.empty(); @@ -88,7 +88,7 @@ public class TlsEdge { this.ipRestriction = ipRestriction != null ? ipRestriction : Optional.empty(); this.mutualTls = mutualTls != null ? mutualTls : Optional.empty(); this.tlsTermination = tlsTermination != null ? tlsTermination : Optional.empty(); - this.policy = policy != null ? policy : Optional.empty(); + this.trafficPolicy = trafficPolicy != null ? trafficPolicy : Optional.empty(); } /** @@ -186,10 +186,10 @@ public class TlsEdge { /** * the traffic policy associated with this edge or null * - * @return the value of the property as a {@link EndpointPolicy} wrapped in an {@link Optional} + * @return the value of the property as a {@link EndpointTrafficPolicy} wrapped in an {@link Optional} */ - public Optional getPolicy() { - return this.policy; + public Optional getTrafficPolicy() { + return this.trafficPolicy; } @Override @@ -213,7 +213,7 @@ public class TlsEdge { this.ipRestriction.equals(other.ipRestriction)&& this.mutualTls.equals(other.mutualTls)&& this.tlsTermination.equals(other.tlsTermination)&& - this.policy.equals(other.policy); + this.trafficPolicy.equals(other.trafficPolicy); } @@ -230,7 +230,7 @@ public class TlsEdge { this.ipRestriction, this.mutualTls, this.tlsTermination, - this.policy + this.trafficPolicy ); } @@ -247,7 +247,7 @@ public class TlsEdge { "', ipRestriction='" + this.ipRestriction.map(Object::toString).orElse("(null)") + "', mutualTls='" + this.mutualTls.map(Object::toString).orElse("(null)") + "', tlsTermination='" + this.tlsTermination.map(Object::toString).orElse("(null)") + - "', policy='" + this.policy.map(Object::toString).orElse("(null)") + + "', trafficPolicy='" + this.trafficPolicy.map(Object::toString).orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/services/EdgeRouteTrafficPolicyModule.java b/src/main/java/com/ngrok/services/EdgeRouteTrafficPolicyModule.java new file mode 100644 index 0000000..f597bed --- /dev/null +++ b/src/main/java/com/ngrok/services/EdgeRouteTrafficPolicyModule.java @@ -0,0 +1,248 @@ +/* Code generated for API Clients. DO NOT EDIT. */ + +package com.ngrok.services; + +import com.ngrok.NgrokApiClient; +import com.ngrok.definitions.*; + +import java.util.AbstractMap; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ExecutionException; +import java.util.function.Function; +import java.util.stream.Stream; + +/** + * An API client for {@link EdgeRouteTrafficPolicyModule}. + * + * See also https://ngrok.com/docs/api#api-edge-route-traffic-policy-module. + */ +public class EdgeRouteTrafficPolicyModule { + private final NgrokApiClient apiClient; + + /** + * Creates a new sub-client for EdgeRouteTrafficPolicyModule. + * + * @param apiClient an instance of {@link com.ngrok.NgrokApiClient} + */ + public EdgeRouteTrafficPolicyModule(final NgrokApiClient apiClient) { + this.apiClient = Objects.requireNonNull(apiClient, "apiClient is required"); + } + + /** + * A builder object encapsulating state for an unsent Replace API call. + */ + public class ReplaceCallBuilder { + private final String edgeId; + private final String id; + private Optional module = Optional.empty(); + + private ReplaceCallBuilder( + final String edgeId, + final String id + ) { + this.edgeId = Objects.requireNonNull(edgeId, "edgeId is required"); + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Sets the module parameter. + * + * @param module the value of the module parameter as a {@link EndpointTrafficPolicy} + * @return the call builder instance + */ + public ReplaceCallBuilder module(final EndpointTrafficPolicy module) { + this.module = Optional.of(Objects.requireNonNull(module, "module is required")); + return this; + } + + /** + * Sets (or unsets) the module parameter. + * + * @param module the value of the module parameter as an {@link Optional} of {@link EndpointTrafficPolicy} + * @return the call builder instance + */ + public ReplaceCallBuilder module(final Optional module) { + this.module = Objects.requireNonNull(module, "module is required"); + return this; + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link EndpointTrafficPolicy} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.PUT, + "/edges/https/" + this.edgeId + "/routes/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.of( + new AbstractMap.SimpleEntry<>("module", this.module.map(Function.identity())) + ), + Optional.of(EndpointTrafficPolicy.class) + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return {@link EndpointTrafficPolicy} + * @throws InterruptedException if the thread was interrupted during the call + */ + public EndpointTrafficPolicy blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Replace API operation. + * + * See also https://ngrok.com/docs/api#api-edge-route-traffic-policy-module-replace. + * + * @param edgeId the value of the edge_id parameter as a {@link String} + * @param id the value of the id parameter as a {@link String} + * @return a call builder for this API call + */ + public ReplaceCallBuilder replace( + final String edgeId, + final String id + ) { + return new ReplaceCallBuilder( + edgeId, + id + ); + } + + /** + * A builder object encapsulating state for an unsent Get API call. + */ + public class GetCallBuilder { + private final String edgeId; + private final String id; + + private GetCallBuilder( + final String edgeId, + final String id + ) { + this.edgeId = Objects.requireNonNull(edgeId, "edgeId is required"); + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link EndpointTrafficPolicy} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.GET, + "/edges/https/" + this.edgeId + "/routes/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.empty(), + Optional.of(EndpointTrafficPolicy.class) + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return {@link EndpointTrafficPolicy} + * @throws InterruptedException if the thread was interrupted during the call + */ + public EndpointTrafficPolicy blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Get API operation. + * + * See also https://ngrok.com/docs/api#api-edge-route-traffic-policy-module-get. + * + * @param edgeId unique identifier of this edge + * @param id unique identifier of this edge route + * @return a call builder for this API call + */ + public GetCallBuilder get( + final String edgeId, + final String id + ) { + return new GetCallBuilder( + edgeId, + id + ); + } + + /** + * A builder object encapsulating state for an unsent Delete API call. + */ + public class DeleteCallBuilder { + private final String edgeId; + private final String id; + + private DeleteCallBuilder( + final String edgeId, + final String id + ) { + this.edgeId = Objects.requireNonNull(edgeId, "edgeId is required"); + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link Void} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.DELETE, + "/edges/https/" + this.edgeId + "/routes/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.empty(), + Optional.empty() + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @throws InterruptedException if the thread was interrupted during the call + */ + public void blockingCall() throws InterruptedException { + try { + call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Delete API operation. + * + * See also https://ngrok.com/docs/api#api-edge-route-traffic-policy-module-delete. + * + * @param edgeId unique identifier of this edge + * @param id unique identifier of this edge route + * @return a call builder for this API call + */ + public DeleteCallBuilder delete( + final String edgeId, + final String id + ) { + return new DeleteCallBuilder( + edgeId, + id + ); + } +} diff --git a/src/main/java/com/ngrok/services/EdgesHttpsRoutes.java b/src/main/java/com/ngrok/services/EdgesHttpsRoutes.java index c63d4d0..6e06d2e 100644 --- a/src/main/java/com/ngrok/services/EdgesHttpsRoutes.java +++ b/src/main/java/com/ngrok/services/EdgesHttpsRoutes.java @@ -51,7 +51,7 @@ public class EdgesHttpsRoutes { private Optional oidc = Optional.empty(); private Optional websocketTcpConverter = Optional.empty(); private Optional userAgentFilter = Optional.empty(); - private Optional policy = Optional.empty(); + private Optional trafficPolicy = Optional.empty(); private CreateCallBuilder( final String edgeId, @@ -378,22 +378,22 @@ public class EdgesHttpsRoutes { /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as a {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as a {@link EndpointTrafficPolicy} * @return the call builder instance */ - public CreateCallBuilder policy(final EndpointPolicy policy) { - this.policy = Optional.of(Objects.requireNonNull(policy, "policy is required")); + public CreateCallBuilder trafficPolicy(final EndpointTrafficPolicy trafficPolicy) { + this.trafficPolicy = Optional.of(Objects.requireNonNull(trafficPolicy, "trafficPolicy is required")); return this; } /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as an {@link Optional} of {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as an {@link Optional} of {@link EndpointTrafficPolicy} * @return the call builder instance */ - public CreateCallBuilder policy(final Optional policy) { - this.policy = Objects.requireNonNull(policy, "policy is required"); + public CreateCallBuilder trafficPolicy(final Optional trafficPolicy) { + this.trafficPolicy = Objects.requireNonNull(trafficPolicy, "trafficPolicy is required"); return this; } @@ -424,7 +424,7 @@ public class EdgesHttpsRoutes { new AbstractMap.SimpleEntry<>("oidc", this.oidc.map(Function.identity())), new AbstractMap.SimpleEntry<>("websocket_tcp_converter", this.websocketTcpConverter.map(Function.identity())), new AbstractMap.SimpleEntry<>("user_agent_filter", this.userAgentFilter.map(Function.identity())), - new AbstractMap.SimpleEntry<>("policy", this.policy.map(Function.identity())) + new AbstractMap.SimpleEntry<>("traffic_policy", this.trafficPolicy.map(Function.identity())) ), Optional.of(HttpsEdgeRoute.class) ); @@ -553,7 +553,7 @@ public class EdgesHttpsRoutes { private Optional oidc = Optional.empty(); private Optional websocketTcpConverter = Optional.empty(); private Optional userAgentFilter = Optional.empty(); - private Optional policy = Optional.empty(); + private Optional trafficPolicy = Optional.empty(); private UpdateCallBuilder( final String edgeId, @@ -926,22 +926,22 @@ public class EdgesHttpsRoutes { /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as a {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as a {@link EndpointTrafficPolicy} * @return the call builder instance */ - public UpdateCallBuilder policy(final EndpointPolicy policy) { - this.policy = Optional.of(Objects.requireNonNull(policy, "policy is required")); + public UpdateCallBuilder trafficPolicy(final EndpointTrafficPolicy trafficPolicy) { + this.trafficPolicy = Optional.of(Objects.requireNonNull(trafficPolicy, "trafficPolicy is required")); return this; } /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as an {@link Optional} of {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as an {@link Optional} of {@link EndpointTrafficPolicy} * @return the call builder instance */ - public UpdateCallBuilder policy(final Optional policy) { - this.policy = Objects.requireNonNull(policy, "policy is required"); + public UpdateCallBuilder trafficPolicy(final Optional trafficPolicy) { + this.trafficPolicy = Objects.requireNonNull(trafficPolicy, "trafficPolicy is required"); return this; } @@ -972,7 +972,7 @@ public class EdgesHttpsRoutes { new AbstractMap.SimpleEntry<>("oidc", this.oidc.map(Function.identity())), new AbstractMap.SimpleEntry<>("websocket_tcp_converter", this.websocketTcpConverter.map(Function.identity())), new AbstractMap.SimpleEntry<>("user_agent_filter", this.userAgentFilter.map(Function.identity())), - new AbstractMap.SimpleEntry<>("policy", this.policy.map(Function.identity())) + new AbstractMap.SimpleEntry<>("traffic_policy", this.trafficPolicy.map(Function.identity())) ), Optional.of(HttpsEdgeRoute.class) ); diff --git a/src/main/java/com/ngrok/services/EdgesTcp.java b/src/main/java/com/ngrok/services/EdgesTcp.java index 6f205a4..886d951 100644 --- a/src/main/java/com/ngrok/services/EdgesTcp.java +++ b/src/main/java/com/ngrok/services/EdgesTcp.java @@ -39,7 +39,7 @@ public class EdgesTcp { private Optional> hostports = Optional.empty(); private Optional backend = Optional.empty(); private Optional ipRestriction = Optional.empty(); - private Optional policy = Optional.empty(); + private Optional trafficPolicy = Optional.empty(); private CreateCallBuilder( ) { @@ -162,22 +162,22 @@ public class EdgesTcp { /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as a {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as a {@link EndpointTrafficPolicy} * @return the call builder instance */ - public CreateCallBuilder policy(final EndpointPolicy policy) { - this.policy = Optional.of(Objects.requireNonNull(policy, "policy is required")); + public CreateCallBuilder trafficPolicy(final EndpointTrafficPolicy trafficPolicy) { + this.trafficPolicy = Optional.of(Objects.requireNonNull(trafficPolicy, "trafficPolicy is required")); return this; } /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as an {@link Optional} of {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as an {@link Optional} of {@link EndpointTrafficPolicy} * @return the call builder instance */ - public CreateCallBuilder policy(final Optional policy) { - this.policy = Objects.requireNonNull(policy, "policy is required"); + public CreateCallBuilder trafficPolicy(final Optional trafficPolicy) { + this.trafficPolicy = Objects.requireNonNull(trafficPolicy, "trafficPolicy is required"); return this; } @@ -197,7 +197,7 @@ public class EdgesTcp { new AbstractMap.SimpleEntry<>("hostports", Optional.of(this.hostports).filter(hostports -> !hostports.isEmpty()).map(Function.identity())), new AbstractMap.SimpleEntry<>("backend", this.backend.map(Function.identity())), new AbstractMap.SimpleEntry<>("ip_restriction", this.ipRestriction.map(Function.identity())), - new AbstractMap.SimpleEntry<>("policy", this.policy.map(Function.identity())) + new AbstractMap.SimpleEntry<>("traffic_policy", this.trafficPolicy.map(Function.identity())) ), Optional.of(TcpEdge.class) ); @@ -400,7 +400,7 @@ public class EdgesTcp { private Optional> hostports = Optional.empty(); private Optional backend = Optional.empty(); private Optional ipRestriction = Optional.empty(); - private Optional policy = Optional.empty(); + private Optional trafficPolicy = Optional.empty(); private UpdateCallBuilder( final String id @@ -525,22 +525,22 @@ public class EdgesTcp { /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as a {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as a {@link EndpointTrafficPolicy} * @return the call builder instance */ - public UpdateCallBuilder policy(final EndpointPolicy policy) { - this.policy = Optional.of(Objects.requireNonNull(policy, "policy is required")); + public UpdateCallBuilder trafficPolicy(final EndpointTrafficPolicy trafficPolicy) { + this.trafficPolicy = Optional.of(Objects.requireNonNull(trafficPolicy, "trafficPolicy is required")); return this; } /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as an {@link Optional} of {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as an {@link Optional} of {@link EndpointTrafficPolicy} * @return the call builder instance */ - public UpdateCallBuilder policy(final Optional policy) { - this.policy = Objects.requireNonNull(policy, "policy is required"); + public UpdateCallBuilder trafficPolicy(final Optional trafficPolicy) { + this.trafficPolicy = Objects.requireNonNull(trafficPolicy, "trafficPolicy is required"); return this; } @@ -560,7 +560,7 @@ public class EdgesTcp { new AbstractMap.SimpleEntry<>("hostports", Optional.of(this.hostports).filter(hostports -> !hostports.isEmpty()).map(Function.identity())), new AbstractMap.SimpleEntry<>("backend", this.backend.map(Function.identity())), new AbstractMap.SimpleEntry<>("ip_restriction", this.ipRestriction.map(Function.identity())), - new AbstractMap.SimpleEntry<>("policy", this.policy.map(Function.identity())) + new AbstractMap.SimpleEntry<>("traffic_policy", this.trafficPolicy.map(Function.identity())) ), Optional.of(TcpEdge.class) ); diff --git a/src/main/java/com/ngrok/services/EdgesTls.java b/src/main/java/com/ngrok/services/EdgesTls.java index a5eaf71..b6952ec 100644 --- a/src/main/java/com/ngrok/services/EdgesTls.java +++ b/src/main/java/com/ngrok/services/EdgesTls.java @@ -41,7 +41,7 @@ public class EdgesTls { private Optional ipRestriction = Optional.empty(); private Optional mutualTls = Optional.empty(); private Optional tlsTermination = Optional.empty(); - private Optional policy = Optional.empty(); + private Optional trafficPolicy = Optional.empty(); private CreateCallBuilder( ) { @@ -208,22 +208,22 @@ public class EdgesTls { /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as a {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as a {@link EndpointTrafficPolicy} * @return the call builder instance */ - public CreateCallBuilder policy(final EndpointPolicy policy) { - this.policy = Optional.of(Objects.requireNonNull(policy, "policy is required")); + public CreateCallBuilder trafficPolicy(final EndpointTrafficPolicy trafficPolicy) { + this.trafficPolicy = Optional.of(Objects.requireNonNull(trafficPolicy, "trafficPolicy is required")); return this; } /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as an {@link Optional} of {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as an {@link Optional} of {@link EndpointTrafficPolicy} * @return the call builder instance */ - public CreateCallBuilder policy(final Optional policy) { - this.policy = Objects.requireNonNull(policy, "policy is required"); + public CreateCallBuilder trafficPolicy(final Optional trafficPolicy) { + this.trafficPolicy = Objects.requireNonNull(trafficPolicy, "trafficPolicy is required"); return this; } @@ -245,7 +245,7 @@ public class EdgesTls { new AbstractMap.SimpleEntry<>("ip_restriction", this.ipRestriction.map(Function.identity())), new AbstractMap.SimpleEntry<>("mutual_tls", this.mutualTls.map(Function.identity())), new AbstractMap.SimpleEntry<>("tls_termination", this.tlsTermination.map(Function.identity())), - new AbstractMap.SimpleEntry<>("policy", this.policy.map(Function.identity())) + new AbstractMap.SimpleEntry<>("traffic_policy", this.trafficPolicy.map(Function.identity())) ), Optional.of(TlsEdge.class) ); @@ -450,7 +450,7 @@ public class EdgesTls { private Optional ipRestriction = Optional.empty(); private Optional mutualTls = Optional.empty(); private Optional tlsTermination = Optional.empty(); - private Optional policy = Optional.empty(); + private Optional trafficPolicy = Optional.empty(); private UpdateCallBuilder( final String id @@ -619,22 +619,22 @@ public class EdgesTls { /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as a {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as a {@link EndpointTrafficPolicy} * @return the call builder instance */ - public UpdateCallBuilder policy(final EndpointPolicy policy) { - this.policy = Optional.of(Objects.requireNonNull(policy, "policy is required")); + public UpdateCallBuilder trafficPolicy(final EndpointTrafficPolicy trafficPolicy) { + this.trafficPolicy = Optional.of(Objects.requireNonNull(trafficPolicy, "trafficPolicy is required")); return this; } /** * the traffic policy associated with this edge or null * - * @param policy the value of the policy parameter as an {@link Optional} of {@link EndpointPolicy} + * @param trafficPolicy the value of the traffic_policy parameter as an {@link Optional} of {@link EndpointTrafficPolicy} * @return the call builder instance */ - public UpdateCallBuilder policy(final Optional policy) { - this.policy = Objects.requireNonNull(policy, "policy is required"); + public UpdateCallBuilder trafficPolicy(final Optional trafficPolicy) { + this.trafficPolicy = Objects.requireNonNull(trafficPolicy, "trafficPolicy is required"); return this; } @@ -656,7 +656,7 @@ public class EdgesTls { new AbstractMap.SimpleEntry<>("ip_restriction", this.ipRestriction.map(Function.identity())), new AbstractMap.SimpleEntry<>("mutual_tls", this.mutualTls.map(Function.identity())), new AbstractMap.SimpleEntry<>("tls_termination", this.tlsTermination.map(Function.identity())), - new AbstractMap.SimpleEntry<>("policy", this.policy.map(Function.identity())) + new AbstractMap.SimpleEntry<>("traffic_policy", this.trafficPolicy.map(Function.identity())) ), Optional.of(TlsEdge.class) ); diff --git a/src/main/java/com/ngrok/services/TcpEdgeTrafficPolicyModule.java b/src/main/java/com/ngrok/services/TcpEdgeTrafficPolicyModule.java new file mode 100644 index 0000000..36b9412 --- /dev/null +++ b/src/main/java/com/ngrok/services/TcpEdgeTrafficPolicyModule.java @@ -0,0 +1,230 @@ +/* Code generated for API Clients. DO NOT EDIT. */ + +package com.ngrok.services; + +import com.ngrok.NgrokApiClient; +import com.ngrok.definitions.*; + +import java.util.AbstractMap; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ExecutionException; +import java.util.function.Function; +import java.util.stream.Stream; + +/** + * An API client for {@link TcpEdgeTrafficPolicyModule}. + * + * See also https://ngrok.com/docs/api#api-tcp-edge-traffic-policy-module. + */ +public class TcpEdgeTrafficPolicyModule { + private final NgrokApiClient apiClient; + + /** + * Creates a new sub-client for TcpEdgeTrafficPolicyModule. + * + * @param apiClient an instance of {@link com.ngrok.NgrokApiClient} + */ + public TcpEdgeTrafficPolicyModule(final NgrokApiClient apiClient) { + this.apiClient = Objects.requireNonNull(apiClient, "apiClient is required"); + } + + /** + * A builder object encapsulating state for an unsent Replace API call. + */ + public class ReplaceCallBuilder { + private final String id; + private Optional module = Optional.empty(); + + private ReplaceCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Sets the module parameter. + * + * @param module the value of the module parameter as a {@link EndpointTrafficPolicy} + * @return the call builder instance + */ + public ReplaceCallBuilder module(final EndpointTrafficPolicy module) { + this.module = Optional.of(Objects.requireNonNull(module, "module is required")); + return this; + } + + /** + * Sets (or unsets) the module parameter. + * + * @param module the value of the module parameter as an {@link Optional} of {@link EndpointTrafficPolicy} + * @return the call builder instance + */ + public ReplaceCallBuilder module(final Optional module) { + this.module = Objects.requireNonNull(module, "module is required"); + return this; + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link EndpointTrafficPolicy} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.PUT, + "/edges/tcp/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.of( + new AbstractMap.SimpleEntry<>("module", this.module.map(Function.identity())) + ), + Optional.of(EndpointTrafficPolicy.class) + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return {@link EndpointTrafficPolicy} + * @throws InterruptedException if the thread was interrupted during the call + */ + public EndpointTrafficPolicy blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Replace API operation. + * + * See also https://ngrok.com/docs/api#api-tcp-edge-traffic-policy-module-replace. + * + * @param id the value of the id parameter as a {@link String} + * @return a call builder for this API call + */ + public ReplaceCallBuilder replace( + final String id + ) { + return new ReplaceCallBuilder( + id + ); + } + + /** + * A builder object encapsulating state for an unsent Get API call. + */ + public class GetCallBuilder { + private final String id; + + private GetCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link EndpointTrafficPolicy} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.GET, + "/edges/tcp/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.empty(), + Optional.of(EndpointTrafficPolicy.class) + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return {@link EndpointTrafficPolicy} + * @throws InterruptedException if the thread was interrupted during the call + */ + public EndpointTrafficPolicy blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Get API operation. + * + * See also https://ngrok.com/docs/api#api-tcp-edge-traffic-policy-module-get. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public GetCallBuilder get( + final String id + ) { + return new GetCallBuilder( + id + ); + } + + /** + * A builder object encapsulating state for an unsent Delete API call. + */ + public class DeleteCallBuilder { + private final String id; + + private DeleteCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link Void} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.DELETE, + "/edges/tcp/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.empty(), + Optional.empty() + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @throws InterruptedException if the thread was interrupted during the call + */ + public void blockingCall() throws InterruptedException { + try { + call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Delete API operation. + * + * See also https://ngrok.com/docs/api#api-tcp-edge-traffic-policy-module-delete. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public DeleteCallBuilder delete( + final String id + ) { + return new DeleteCallBuilder( + id + ); + } +} diff --git a/src/main/java/com/ngrok/services/TlsEdgeTrafficPolicyModule.java b/src/main/java/com/ngrok/services/TlsEdgeTrafficPolicyModule.java new file mode 100644 index 0000000..8e9ede4 --- /dev/null +++ b/src/main/java/com/ngrok/services/TlsEdgeTrafficPolicyModule.java @@ -0,0 +1,230 @@ +/* Code generated for API Clients. DO NOT EDIT. */ + +package com.ngrok.services; + +import com.ngrok.NgrokApiClient; +import com.ngrok.definitions.*; + +import java.util.AbstractMap; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ExecutionException; +import java.util.function.Function; +import java.util.stream.Stream; + +/** + * An API client for {@link TlsEdgeTrafficPolicyModule}. + * + * See also https://ngrok.com/docs/api#api-tls-edge-traffic-policy-module. + */ +public class TlsEdgeTrafficPolicyModule { + private final NgrokApiClient apiClient; + + /** + * Creates a new sub-client for TlsEdgeTrafficPolicyModule. + * + * @param apiClient an instance of {@link com.ngrok.NgrokApiClient} + */ + public TlsEdgeTrafficPolicyModule(final NgrokApiClient apiClient) { + this.apiClient = Objects.requireNonNull(apiClient, "apiClient is required"); + } + + /** + * A builder object encapsulating state for an unsent Replace API call. + */ + public class ReplaceCallBuilder { + private final String id; + private Optional module = Optional.empty(); + + private ReplaceCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Sets the module parameter. + * + * @param module the value of the module parameter as a {@link EndpointTrafficPolicy} + * @return the call builder instance + */ + public ReplaceCallBuilder module(final EndpointTrafficPolicy module) { + this.module = Optional.of(Objects.requireNonNull(module, "module is required")); + return this; + } + + /** + * Sets (or unsets) the module parameter. + * + * @param module the value of the module parameter as an {@link Optional} of {@link EndpointTrafficPolicy} + * @return the call builder instance + */ + public ReplaceCallBuilder module(final Optional module) { + this.module = Objects.requireNonNull(module, "module is required"); + return this; + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link EndpointTrafficPolicy} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.PUT, + "/edges/tls/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.of( + new AbstractMap.SimpleEntry<>("module", this.module.map(Function.identity())) + ), + Optional.of(EndpointTrafficPolicy.class) + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return {@link EndpointTrafficPolicy} + * @throws InterruptedException if the thread was interrupted during the call + */ + public EndpointTrafficPolicy blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Replace API operation. + * + * See also https://ngrok.com/docs/api#api-tls-edge-traffic-policy-module-replace. + * + * @param id the value of the id parameter as a {@link String} + * @return a call builder for this API call + */ + public ReplaceCallBuilder replace( + final String id + ) { + return new ReplaceCallBuilder( + id + ); + } + + /** + * A builder object encapsulating state for an unsent Get API call. + */ + public class GetCallBuilder { + private final String id; + + private GetCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link EndpointTrafficPolicy} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.GET, + "/edges/tls/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.empty(), + Optional.of(EndpointTrafficPolicy.class) + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return {@link EndpointTrafficPolicy} + * @throws InterruptedException if the thread was interrupted during the call + */ + public EndpointTrafficPolicy blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Get API operation. + * + * See also https://ngrok.com/docs/api#api-tls-edge-traffic-policy-module-get. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public GetCallBuilder get( + final String id + ) { + return new GetCallBuilder( + id + ); + } + + /** + * A builder object encapsulating state for an unsent Delete API call. + */ + public class DeleteCallBuilder { + private final String id; + + private DeleteCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link Void} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.DELETE, + "/edges/tls/" + this.id + "/traffic_policy", + Stream.empty(), + Stream.empty(), + Optional.empty() + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @throws InterruptedException if the thread was interrupted during the call + */ + public void blockingCall() throws InterruptedException { + try { + call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Creates a call builder for the Delete API operation. + * + * See also https://ngrok.com/docs/api#api-tls-edge-traffic-policy-module-delete. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public DeleteCallBuilder delete( + final String id + ) { + return new DeleteCallBuilder( + id + ); + } +}