diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/AddRuleSecurityPolicyHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/AddRuleSecurityPolicyHttpRequest.java new file mode 100644 index 000000000000..16f369013b83 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/AddRuleSecurityPolicyHttpRequest.java @@ -0,0 +1,413 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class AddRuleSecurityPolicyHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String key; + private final String prettyPrint; + private final String quotaUser; + private final String securityPolicy; + private final SecurityPolicyRule securityPolicyRuleResource; + private final String userIp; + + private AddRuleSecurityPolicyHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.quotaUser = null; + this.securityPolicy = null; + this.securityPolicyRuleResource = null; + this.userIp = null; + } + + private AddRuleSecurityPolicyHttpRequest( + String access_token, + String callback, + String fields, + String key, + String prettyPrint, + String quotaUser, + String securityPolicy, + SecurityPolicyRule securityPolicyRuleResource, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.quotaUser = quotaUser; + this.securityPolicy = securityPolicy; + this.securityPolicyRuleResource = securityPolicyRuleResource; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } + if (fieldName.equals("securityPolicyRuleResource")) { + return securityPolicyRuleResource; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public SecurityPolicyRule getApiMessageRequestBody() { + return securityPolicyRuleResource; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public SecurityPolicyRule getSecurityPolicyRuleResource() { + return securityPolicyRuleResource; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(AddRuleSecurityPolicyHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static AddRuleSecurityPolicyHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final AddRuleSecurityPolicyHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new AddRuleSecurityPolicyHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String key; + private String prettyPrint; + private String quotaUser; + private String securityPolicy; + private SecurityPolicyRule securityPolicyRuleResource; + private String userIp; + + Builder() {} + + public Builder mergeFrom(AddRuleSecurityPolicyHttpRequest other) { + if (other == AddRuleSecurityPolicyHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } + if (other.getSecurityPolicyRuleResource() != null) { + this.securityPolicyRuleResource = other.securityPolicyRuleResource; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(AddRuleSecurityPolicyHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.quotaUser = source.quotaUser; + this.securityPolicy = source.securityPolicy; + this.securityPolicyRuleResource = source.securityPolicyRuleResource; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + public SecurityPolicyRule getSecurityPolicyRuleResource() { + return securityPolicyRuleResource; + } + + public Builder setSecurityPolicyRuleResource(SecurityPolicyRule securityPolicyRuleResource) { + this.securityPolicyRuleResource = securityPolicyRuleResource; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public AddRuleSecurityPolicyHttpRequest build() { + String missing = ""; + + if (securityPolicy == null) { + missing += " securityPolicy"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new AddRuleSecurityPolicyHttpRequest( + access_token, + callback, + fields, + key, + prettyPrint, + quotaUser, + securityPolicy, + securityPolicyRuleResource, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setSecurityPolicy(this.securityPolicy); + newBuilder.setSecurityPolicyRuleResource(this.securityPolicyRuleResource); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "AddRuleSecurityPolicyHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "securityPolicy=" + + securityPolicy + + ", " + + "securityPolicyRuleResource=" + + securityPolicyRuleResource + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof AddRuleSecurityPolicyHttpRequest) { + AddRuleSecurityPolicyHttpRequest that = (AddRuleSecurityPolicyHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()) + && Objects.equals(this.securityPolicyRuleResource, that.getSecurityPolicyRuleResource()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + callback, + fields, + key, + prettyPrint, + quotaUser, + securityPolicy, + securityPolicyRuleResource, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/AttachedDiskInitializeParams.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/AttachedDiskInitializeParams.java index ca7015f26d13..7ebb0a5010dd 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/AttachedDiskInitializeParams.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/AttachedDiskInitializeParams.java @@ -26,6 +26,7 @@ @Generated("by GAPIC") @BetaApi public final class AttachedDiskInitializeParams implements ApiMessage { + private final String description; private final String diskName; private final String diskSizeGb; private final String diskType; @@ -34,6 +35,7 @@ public final class AttachedDiskInitializeParams implements ApiMessage { private final CustomerEncryptionKey sourceImageEncryptionKey; private AttachedDiskInitializeParams() { + this.description = null; this.diskName = null; this.diskSizeGb = null; this.diskType = null; @@ -43,12 +45,14 @@ private AttachedDiskInitializeParams() { } private AttachedDiskInitializeParams( + String description, String diskName, String diskSizeGb, String diskType, Map labels, String sourceImage, CustomerEncryptionKey sourceImageEncryptionKey) { + this.description = description; this.diskName = diskName; this.diskSizeGb = diskSizeGb; this.diskType = diskType; @@ -59,6 +63,9 @@ private AttachedDiskInitializeParams( @Override public Object getFieldValue(String fieldName) { + if (fieldName.equals("description")) { + return description; + } if (fieldName.equals("diskName")) { return diskName; } @@ -92,6 +99,10 @@ public List getFieldMask() { return null; } + public String getDescription() { + return description; + } + public String getDiskName() { return diskName; } @@ -139,6 +150,7 @@ public static AttachedDiskInitializeParams getDefaultInstance() { } public static class Builder { + private String description; private String diskName; private String diskSizeGb; private String diskType; @@ -150,6 +162,9 @@ public static class Builder { public Builder mergeFrom(AttachedDiskInitializeParams other) { if (other == AttachedDiskInitializeParams.getDefaultInstance()) return this; + if (other.getDescription() != null) { + this.description = other.description; + } if (other.getDiskName() != null) { this.diskName = other.diskName; } @@ -172,6 +187,7 @@ public Builder mergeFrom(AttachedDiskInitializeParams other) { } Builder(AttachedDiskInitializeParams source) { + this.description = source.description; this.diskName = source.diskName; this.diskSizeGb = source.diskSizeGb; this.diskType = source.diskType; @@ -180,6 +196,15 @@ public Builder mergeFrom(AttachedDiskInitializeParams other) { this.sourceImageEncryptionKey = source.sourceImageEncryptionKey; } + public String getDescription() { + return description; + } + + public Builder setDescription(String description) { + this.description = description; + return this; + } + public String getDiskName() { return diskName; } @@ -237,11 +262,18 @@ public Builder setSourceImageEncryptionKey(CustomerEncryptionKey sourceImageEncr public AttachedDiskInitializeParams build() { return new AttachedDiskInitializeParams( - diskName, diskSizeGb, diskType, labels, sourceImage, sourceImageEncryptionKey); + description, + diskName, + diskSizeGb, + diskType, + labels, + sourceImage, + sourceImageEncryptionKey); } public Builder clone() { Builder newBuilder = new Builder(); + newBuilder.setDescription(this.description); newBuilder.setDiskName(this.diskName); newBuilder.setDiskSizeGb(this.diskSizeGb); newBuilder.setDiskType(this.diskType); @@ -255,6 +287,9 @@ public Builder clone() { @Override public String toString() { return "AttachedDiskInitializeParams{" + + "description=" + + description + + ", " + "diskName=" + diskName + ", " @@ -282,7 +317,8 @@ public boolean equals(Object o) { } if (o instanceof AttachedDiskInitializeParams) { AttachedDiskInitializeParams that = (AttachedDiskInitializeParams) o; - return Objects.equals(this.diskName, that.getDiskName()) + return Objects.equals(this.description, that.getDescription()) + && Objects.equals(this.diskName, that.getDiskName()) && Objects.equals(this.diskSizeGb, that.getDiskSizeGb()) && Objects.equals(this.diskType, that.getDiskType()) && Objects.equals(this.labels, that.getLabelsMap()) @@ -295,6 +331,6 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - diskName, diskSizeGb, diskType, labels, sourceImage, sourceImageEncryptionKey); + description, diskName, diskSizeGb, diskType, labels, sourceImage, sourceImageEncryptionKey); } } diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendService.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendService.java index cacfdf63abb6..eb8b8690523d 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendService.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendService.java @@ -44,6 +44,7 @@ public final class BackendService implements ApiMessage { private final String portName; private final String protocol; private final String region; + private final String securityPolicy; private final String selfLink; private final String sessionAffinity; private final Integer timeoutSec; @@ -67,6 +68,7 @@ private BackendService() { this.portName = null; this.protocol = null; this.region = null; + this.securityPolicy = null; this.selfLink = null; this.sessionAffinity = null; this.timeoutSec = null; @@ -91,6 +93,7 @@ private BackendService( String portName, String protocol, String region, + String securityPolicy, String selfLink, String sessionAffinity, Integer timeoutSec) { @@ -112,6 +115,7 @@ private BackendService( this.portName = portName; this.protocol = protocol; this.region = region; + this.securityPolicy = securityPolicy; this.selfLink = selfLink; this.sessionAffinity = sessionAffinity; this.timeoutSec = timeoutSec; @@ -173,6 +177,9 @@ public Object getFieldValue(String fieldName) { if (fieldName.equals("region")) { return region; } + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } if (fieldName.equals("selfLink")) { return selfLink; } @@ -269,6 +276,10 @@ public String getRegion() { return region; } + public String getSecurityPolicy() { + return securityPolicy; + } + public String getSelfLink() { return selfLink; } @@ -322,6 +333,7 @@ public static class Builder { private String portName; private String protocol; private String region; + private String securityPolicy; private String selfLink; private String sessionAffinity; private Integer timeoutSec; @@ -384,6 +396,9 @@ public Builder mergeFrom(BackendService other) { if (other.getRegion() != null) { this.region = other.region; } + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } if (other.getSelfLink() != null) { this.selfLink = other.selfLink; } @@ -415,6 +430,7 @@ public Builder mergeFrom(BackendService other) { this.portName = source.portName; this.protocol = source.protocol; this.region = source.region; + this.securityPolicy = source.securityPolicy; this.selfLink = source.selfLink; this.sessionAffinity = source.sessionAffinity; this.timeoutSec = source.timeoutSec; @@ -604,6 +620,15 @@ public Builder setRegion(String region) { return this; } + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + public String getSelfLink() { return selfLink; } @@ -652,6 +677,7 @@ public BackendService build() { portName, protocol, region, + securityPolicy, selfLink, sessionAffinity, timeoutSec); @@ -677,6 +703,7 @@ public Builder clone() { newBuilder.setPortName(this.portName); newBuilder.setProtocol(this.protocol); newBuilder.setRegion(this.region); + newBuilder.setSecurityPolicy(this.securityPolicy); newBuilder.setSelfLink(this.selfLink); newBuilder.setSessionAffinity(this.sessionAffinity); newBuilder.setTimeoutSec(this.timeoutSec); @@ -741,6 +768,9 @@ public String toString() { + "region=" + region + ", " + + "securityPolicy=" + + securityPolicy + + ", " + "selfLink=" + selfLink + ", " @@ -777,6 +807,7 @@ public boolean equals(Object o) { && Objects.equals(this.portName, that.getPortName()) && Objects.equals(this.protocol, that.getProtocol()) && Objects.equals(this.region, that.getRegion()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()) && Objects.equals(this.selfLink, that.getSelfLink()) && Objects.equals(this.sessionAffinity, that.getSessionAffinity()) && Objects.equals(this.timeoutSec, that.getTimeoutSec()); @@ -805,6 +836,7 @@ public int hashCode() { portName, protocol, region, + securityPolicy, selfLink, sessionAffinity, timeoutSec); diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendServiceClient.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendServiceClient.java index ac96f1aeff4a..90277f9df91b 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendServiceClient.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendServiceClient.java @@ -1248,6 +1248,122 @@ public final Operation patchBackendService(PatchBackendServiceHttpRequest reques return stub.patchBackendServiceCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Sets the security policy for the specified backend service. + * + *

Sample code: + * + *


+   * try (BackendServiceClient backendServiceClient = BackendServiceClient.create()) {
+   *   ProjectGlobalBackendServiceName backendService = ProjectGlobalBackendServiceName.of("[PROJECT]", "[BACKEND_SERVICE]");
+   *   SecurityPolicyReference securityPolicyReferenceResource = SecurityPolicyReference.newBuilder().build();
+   *   Operation response = backendServiceClient.setSecurityPolicyBackendService(backendService, securityPolicyReferenceResource);
+   * }
+   * 
+ * + * @param backendService Name of the BackendService resource to which the security policy should + * be set. The name should conform to RFC1035. + * @param securityPolicyReferenceResource + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation setSecurityPolicyBackendService( + ProjectGlobalBackendServiceName backendService, + SecurityPolicyReference securityPolicyReferenceResource) { + + SetSecurityPolicyBackendServiceHttpRequest request = + SetSecurityPolicyBackendServiceHttpRequest.newBuilder() + .setBackendService(backendService == null ? null : backendService.toString()) + .setSecurityPolicyReferenceResource(securityPolicyReferenceResource) + .build(); + return setSecurityPolicyBackendService(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Sets the security policy for the specified backend service. + * + *

Sample code: + * + *


+   * try (BackendServiceClient backendServiceClient = BackendServiceClient.create()) {
+   *   ProjectGlobalBackendServiceName backendService = ProjectGlobalBackendServiceName.of("[PROJECT]", "[BACKEND_SERVICE]");
+   *   SecurityPolicyReference securityPolicyReferenceResource = SecurityPolicyReference.newBuilder().build();
+   *   Operation response = backendServiceClient.setSecurityPolicyBackendService(backendService.toString(), securityPolicyReferenceResource);
+   * }
+   * 
+ * + * @param backendService Name of the BackendService resource to which the security policy should + * be set. The name should conform to RFC1035. + * @param securityPolicyReferenceResource + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation setSecurityPolicyBackendService( + String backendService, SecurityPolicyReference securityPolicyReferenceResource) { + + SetSecurityPolicyBackendServiceHttpRequest request = + SetSecurityPolicyBackendServiceHttpRequest.newBuilder() + .setBackendService(backendService) + .setSecurityPolicyReferenceResource(securityPolicyReferenceResource) + .build(); + return setSecurityPolicyBackendService(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Sets the security policy for the specified backend service. + * + *

Sample code: + * + *


+   * try (BackendServiceClient backendServiceClient = BackendServiceClient.create()) {
+   *   ProjectGlobalBackendServiceName backendService = ProjectGlobalBackendServiceName.of("[PROJECT]", "[BACKEND_SERVICE]");
+   *   SecurityPolicyReference securityPolicyReferenceResource = SecurityPolicyReference.newBuilder().build();
+   *   SetSecurityPolicyBackendServiceHttpRequest request = SetSecurityPolicyBackendServiceHttpRequest.newBuilder()
+   *     .setBackendService(backendService.toString())
+   *     .setSecurityPolicyReferenceResource(securityPolicyReferenceResource)
+   *     .build();
+   *   Operation response = backendServiceClient.setSecurityPolicyBackendService(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation setSecurityPolicyBackendService( + SetSecurityPolicyBackendServiceHttpRequest request) { + return setSecurityPolicyBackendServiceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Sets the security policy for the specified backend service. + * + *

Sample code: + * + *


+   * try (BackendServiceClient backendServiceClient = BackendServiceClient.create()) {
+   *   ProjectGlobalBackendServiceName backendService = ProjectGlobalBackendServiceName.of("[PROJECT]", "[BACKEND_SERVICE]");
+   *   SecurityPolicyReference securityPolicyReferenceResource = SecurityPolicyReference.newBuilder().build();
+   *   SetSecurityPolicyBackendServiceHttpRequest request = SetSecurityPolicyBackendServiceHttpRequest.newBuilder()
+   *     .setBackendService(backendService.toString())
+   *     .setSecurityPolicyReferenceResource(securityPolicyReferenceResource)
+   *     .build();
+   *   ApiFuture<Operation> future = backendServiceClient.setSecurityPolicyBackendServiceCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + setSecurityPolicyBackendServiceCallable() { + return stub.setSecurityPolicyBackendServiceCallable(); + } + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Updates the specified BackendService resource with the data included in the request. There are diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendServiceSettings.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendServiceSettings.java index 90b65a13c5e2..58305a2ff5c8 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendServiceSettings.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendServiceSettings.java @@ -122,6 +122,13 @@ public class BackendServiceSettings extends ClientSettings + setSecurityPolicyBackendServiceSettings() { + return ((BackendServiceStubSettings) getStubSettings()) + .setSecurityPolicyBackendServiceSettings(); + } + /** Returns the object with the settings used for calls to updateBackendService. */ public UnaryCallSettings updateBackendServiceSettings() { @@ -287,6 +294,12 @@ public Builder applyToAllUnaryMethods( return getStubSettingsBuilder().patchBackendServiceSettings(); } + /** Returns the builder for the settings used for calls to setSecurityPolicyBackendService. */ + public UnaryCallSettings.Builder + setSecurityPolicyBackendServiceSettings() { + return getStubSettingsBuilder().setSecurityPolicyBackendServiceSettings(); + } + /** Returns the builder for the settings used for calls to updateBackendService. */ public UnaryCallSettings.Builder updateBackendServiceSettings() { diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/DeleteSecurityPolicyHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/DeleteSecurityPolicyHttpRequest.java new file mode 100644 index 000000000000..1ba32b36964b --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/DeleteSecurityPolicyHttpRequest.java @@ -0,0 +1,413 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class DeleteSecurityPolicyHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String key; + private final String prettyPrint; + private final String quotaUser; + private final String requestId; + private final String securityPolicy; + private final String userIp; + + private DeleteSecurityPolicyHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.quotaUser = null; + this.requestId = null; + this.securityPolicy = null; + this.userIp = null; + } + + private DeleteSecurityPolicyHttpRequest( + String access_token, + String callback, + String fields, + String key, + String prettyPrint, + String quotaUser, + String requestId, + String securityPolicy, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.quotaUser = quotaUser; + this.requestId = requestId; + this.securityPolicy = securityPolicy; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("requestId")) { + return requestId; + } + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getRequestId() { + return requestId; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(DeleteSecurityPolicyHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static DeleteSecurityPolicyHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final DeleteSecurityPolicyHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new DeleteSecurityPolicyHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String key; + private String prettyPrint; + private String quotaUser; + private String requestId; + private String securityPolicy; + private String userIp; + + Builder() {} + + public Builder mergeFrom(DeleteSecurityPolicyHttpRequest other) { + if (other == DeleteSecurityPolicyHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getRequestId() != null) { + this.requestId = other.requestId; + } + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(DeleteSecurityPolicyHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.quotaUser = source.quotaUser; + this.requestId = source.requestId; + this.securityPolicy = source.securityPolicy; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getRequestId() { + return requestId; + } + + public Builder setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public DeleteSecurityPolicyHttpRequest build() { + String missing = ""; + + if (securityPolicy == null) { + missing += " securityPolicy"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new DeleteSecurityPolicyHttpRequest( + access_token, + callback, + fields, + key, + prettyPrint, + quotaUser, + requestId, + securityPolicy, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setRequestId(this.requestId); + newBuilder.setSecurityPolicy(this.securityPolicy); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "DeleteSecurityPolicyHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "requestId=" + + requestId + + ", " + + "securityPolicy=" + + securityPolicy + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof DeleteSecurityPolicyHttpRequest) { + DeleteSecurityPolicyHttpRequest that = (DeleteSecurityPolicyHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.requestId, that.getRequestId()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + callback, + fields, + key, + prettyPrint, + quotaUser, + requestId, + securityPolicy, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/Firewall.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/Firewall.java index e10e4a3e0c4f..8ec6a06c3057 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/Firewall.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/Firewall.java @@ -32,6 +32,7 @@ public final class Firewall implements ApiMessage { private final String description; private final List destinationRanges; private final String direction; + private final Boolean disabled; private final String id; private final String kind; private final String name; @@ -51,6 +52,7 @@ private Firewall() { this.description = null; this.destinationRanges = null; this.direction = null; + this.disabled = null; this.id = null; this.kind = null; this.name = null; @@ -71,6 +73,7 @@ private Firewall( String description, List destinationRanges, String direction, + Boolean disabled, String id, String kind, String name, @@ -88,6 +91,7 @@ private Firewall( this.description = description; this.destinationRanges = destinationRanges; this.direction = direction; + this.disabled = disabled; this.id = id; this.kind = kind; this.name = name; @@ -121,6 +125,9 @@ public Object getFieldValue(String fieldName) { if (fieldName.equals("direction")) { return direction; } + if (fieldName.equals("disabled")) { + return disabled; + } if (fieldName.equals("id")) { return id; } @@ -193,6 +200,10 @@ public String getDirection() { return direction; } + public Boolean getDisabled() { + return disabled; + } + public String getId() { return id; } @@ -266,6 +277,7 @@ public static class Builder { private String description; private List destinationRanges; private String direction; + private Boolean disabled; private String id; private String kind; private String name; @@ -300,6 +312,9 @@ public Builder mergeFrom(Firewall other) { if (other.getDirection() != null) { this.direction = other.direction; } + if (other.getDisabled() != null) { + this.disabled = other.disabled; + } if (other.getId() != null) { this.id = other.id; } @@ -343,6 +358,7 @@ public Builder mergeFrom(Firewall other) { this.description = source.description; this.destinationRanges = source.destinationRanges; this.direction = source.direction; + this.disabled = source.disabled; this.id = source.id; this.kind = source.kind; this.name = source.name; @@ -443,6 +459,15 @@ public Builder setDirection(String direction) { return this; } + public Boolean getDisabled() { + return disabled; + } + + public Builder setDisabled(Boolean disabled) { + this.disabled = disabled; + return this; + } + public String getId() { return id; } @@ -606,6 +631,7 @@ public Firewall build() { description, destinationRanges, direction, + disabled, id, kind, name, @@ -627,6 +653,7 @@ public Builder clone() { newBuilder.setDescription(this.description); newBuilder.addAllDestinationRanges(this.destinationRanges); newBuilder.setDirection(this.direction); + newBuilder.setDisabled(this.disabled); newBuilder.setId(this.id); newBuilder.setKind(this.kind); newBuilder.setName(this.name); @@ -663,6 +690,9 @@ public String toString() { + "direction=" + direction + ", " + + "disabled=" + + disabled + + ", " + "id=" + id + ", " @@ -711,6 +741,7 @@ public boolean equals(Object o) { && Objects.equals(this.description, that.getDescription()) && Objects.equals(this.destinationRanges, that.getDestinationRangesList()) && Objects.equals(this.direction, that.getDirection()) + && Objects.equals(this.disabled, that.getDisabled()) && Objects.equals(this.id, that.getId()) && Objects.equals(this.kind, that.getKind()) && Objects.equals(this.name, that.getName()) @@ -735,6 +766,7 @@ public int hashCode() { description, destinationRanges, direction, + disabled, id, kind, name, diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/GetRuleSecurityPolicyHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/GetRuleSecurityPolicyHttpRequest.java new file mode 100644 index 000000000000..46ec1b28eb63 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/GetRuleSecurityPolicyHttpRequest.java @@ -0,0 +1,413 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class GetRuleSecurityPolicyHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String key; + private final String prettyPrint; + private final Integer priority; + private final String quotaUser; + private final String securityPolicy; + private final String userIp; + + private GetRuleSecurityPolicyHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.priority = null; + this.quotaUser = null; + this.securityPolicy = null; + this.userIp = null; + } + + private GetRuleSecurityPolicyHttpRequest( + String access_token, + String callback, + String fields, + String key, + String prettyPrint, + Integer priority, + String quotaUser, + String securityPolicy, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.priority = priority; + this.quotaUser = quotaUser; + this.securityPolicy = securityPolicy; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("priority")) { + return priority; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Integer getPriority() { + return priority; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(GetRuleSecurityPolicyHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static GetRuleSecurityPolicyHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final GetRuleSecurityPolicyHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new GetRuleSecurityPolicyHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String key; + private String prettyPrint; + private Integer priority; + private String quotaUser; + private String securityPolicy; + private String userIp; + + Builder() {} + + public Builder mergeFrom(GetRuleSecurityPolicyHttpRequest other) { + if (other == GetRuleSecurityPolicyHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getPriority() != null) { + this.priority = other.priority; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(GetRuleSecurityPolicyHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.priority = source.priority; + this.quotaUser = source.quotaUser; + this.securityPolicy = source.securityPolicy; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public Integer getPriority() { + return priority; + } + + public Builder setPriority(Integer priority) { + this.priority = priority; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public GetRuleSecurityPolicyHttpRequest build() { + String missing = ""; + + if (securityPolicy == null) { + missing += " securityPolicy"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new GetRuleSecurityPolicyHttpRequest( + access_token, + callback, + fields, + key, + prettyPrint, + priority, + quotaUser, + securityPolicy, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setPriority(this.priority); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setSecurityPolicy(this.securityPolicy); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "GetRuleSecurityPolicyHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "priority=" + + priority + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "securityPolicy=" + + securityPolicy + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof GetRuleSecurityPolicyHttpRequest) { + GetRuleSecurityPolicyHttpRequest that = (GetRuleSecurityPolicyHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.priority, that.getPriority()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + callback, + fields, + key, + prettyPrint, + priority, + quotaUser, + securityPolicy, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/GetSecurityPolicyHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/GetSecurityPolicyHttpRequest.java new file mode 100644 index 000000000000..0cab721fc061 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/GetSecurityPolicyHttpRequest.java @@ -0,0 +1,367 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class GetSecurityPolicyHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String key; + private final String prettyPrint; + private final String quotaUser; + private final String securityPolicy; + private final String userIp; + + private GetSecurityPolicyHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.quotaUser = null; + this.securityPolicy = null; + this.userIp = null; + } + + private GetSecurityPolicyHttpRequest( + String access_token, + String callback, + String fields, + String key, + String prettyPrint, + String quotaUser, + String securityPolicy, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.quotaUser = quotaUser; + this.securityPolicy = securityPolicy; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(GetSecurityPolicyHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static GetSecurityPolicyHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final GetSecurityPolicyHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new GetSecurityPolicyHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String key; + private String prettyPrint; + private String quotaUser; + private String securityPolicy; + private String userIp; + + Builder() {} + + public Builder mergeFrom(GetSecurityPolicyHttpRequest other) { + if (other == GetSecurityPolicyHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(GetSecurityPolicyHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.quotaUser = source.quotaUser; + this.securityPolicy = source.securityPolicy; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public GetSecurityPolicyHttpRequest build() { + String missing = ""; + + if (securityPolicy == null) { + missing += " securityPolicy"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new GetSecurityPolicyHttpRequest( + access_token, callback, fields, key, prettyPrint, quotaUser, securityPolicy, userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setSecurityPolicy(this.securityPolicy); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "GetSecurityPolicyHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "securityPolicy=" + + securityPolicy + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof GetSecurityPolicyHttpRequest) { + GetSecurityPolicyHttpRequest that = (GetSecurityPolicyHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, callback, fields, key, prettyPrint, quotaUser, securityPolicy, userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InsertSecurityPolicyHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InsertSecurityPolicyHttpRequest.java new file mode 100644 index 000000000000..e4281da1109f --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InsertSecurityPolicyHttpRequest.java @@ -0,0 +1,445 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class InsertSecurityPolicyHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String key; + private final String prettyPrint; + private final String project; + private final String quotaUser; + private final String requestId; + private final SecurityPolicy securityPolicyResource; + private final String userIp; + + private InsertSecurityPolicyHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.project = null; + this.quotaUser = null; + this.requestId = null; + this.securityPolicyResource = null; + this.userIp = null; + } + + private InsertSecurityPolicyHttpRequest( + String access_token, + String callback, + String fields, + String key, + String prettyPrint, + String project, + String quotaUser, + String requestId, + SecurityPolicy securityPolicyResource, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.project = project; + this.quotaUser = quotaUser; + this.requestId = requestId; + this.securityPolicyResource = securityPolicyResource; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("project")) { + return project; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("requestId")) { + return requestId; + } + if (fieldName.equals("securityPolicyResource")) { + return securityPolicyResource; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public SecurityPolicy getApiMessageRequestBody() { + return securityPolicyResource; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public String getProject() { + return project; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getRequestId() { + return requestId; + } + + public SecurityPolicy getSecurityPolicyResource() { + return securityPolicyResource; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(InsertSecurityPolicyHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static InsertSecurityPolicyHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final InsertSecurityPolicyHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new InsertSecurityPolicyHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String key; + private String prettyPrint; + private String project; + private String quotaUser; + private String requestId; + private SecurityPolicy securityPolicyResource; + private String userIp; + + Builder() {} + + public Builder mergeFrom(InsertSecurityPolicyHttpRequest other) { + if (other == InsertSecurityPolicyHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getProject() != null) { + this.project = other.project; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getRequestId() != null) { + this.requestId = other.requestId; + } + if (other.getSecurityPolicyResource() != null) { + this.securityPolicyResource = other.securityPolicyResource; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(InsertSecurityPolicyHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.project = source.project; + this.quotaUser = source.quotaUser; + this.requestId = source.requestId; + this.securityPolicyResource = source.securityPolicyResource; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public String getProject() { + return project; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getRequestId() { + return requestId; + } + + public Builder setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public SecurityPolicy getSecurityPolicyResource() { + return securityPolicyResource; + } + + public Builder setSecurityPolicyResource(SecurityPolicy securityPolicyResource) { + this.securityPolicyResource = securityPolicyResource; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public InsertSecurityPolicyHttpRequest build() { + String missing = ""; + + if (project == null) { + missing += " project"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new InsertSecurityPolicyHttpRequest( + access_token, + callback, + fields, + key, + prettyPrint, + project, + quotaUser, + requestId, + securityPolicyResource, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setProject(this.project); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setRequestId(this.requestId); + newBuilder.setSecurityPolicyResource(this.securityPolicyResource); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "InsertSecurityPolicyHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "project=" + + project + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "requestId=" + + requestId + + ", " + + "securityPolicyResource=" + + securityPolicyResource + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof InsertSecurityPolicyHttpRequest) { + InsertSecurityPolicyHttpRequest that = (InsertSecurityPolicyHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.project, that.getProject()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.requestId, that.getRequestId()) + && Objects.equals(this.securityPolicyResource, that.getSecurityPolicyResource()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + callback, + fields, + key, + prettyPrint, + project, + quotaUser, + requestId, + securityPolicyResource, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceClient.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceClient.java index 42a6e553a0d7..b1c3521554e2 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceClient.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceClient.java @@ -280,7 +280,7 @@ public final Operation addAccessConfigInstance(AddAccessConfigInstanceHttpReques // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Retrieves aggregated list of instances. + * Retrieves aggregated list of all of the instances in your project across all regions and zones. * *

Sample code: * @@ -307,7 +307,7 @@ public final AggregatedListInstancesPagedResponse aggregatedListInstances(Projec // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Retrieves aggregated list of instances. + * Retrieves aggregated list of all of the instances in your project across all regions and zones. * *

Sample code: * @@ -332,7 +332,7 @@ public final AggregatedListInstancesPagedResponse aggregatedListInstances(String // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Retrieves aggregated list of instances. + * Retrieves aggregated list of all of the instances in your project across all regions and zones. * *

Sample code: * @@ -359,7 +359,7 @@ public final AggregatedListInstancesPagedResponse aggregatedListInstances( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Retrieves aggregated list of instances. + * Retrieves aggregated list of all of the instances in your project across all regions and zones. * *

Sample code: * @@ -386,7 +386,7 @@ public final AggregatedListInstancesPagedResponse aggregatedListInstances( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Retrieves aggregated list of instances. + * Retrieves aggregated list of all of the instances in your project across all regions and zones. * *

Sample code: * @@ -985,7 +985,7 @@ public final UnaryCallable getInstanceCallable // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Returns the specified instance's serial port output. + * Returns the last 1 MB of serial port output from the specified instance. * *

Sample code: * @@ -1021,7 +1021,7 @@ public final SerialPortOutput getSerialPortOutputInstance( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Returns the specified instance's serial port output. + * Returns the last 1 MB of serial port output from the specified instance. * *

Sample code: * @@ -1057,7 +1057,7 @@ public final SerialPortOutput getSerialPortOutputInstance( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Returns the specified instance's serial port output. + * Returns the last 1 MB of serial port output from the specified instance. * *

Sample code: * @@ -1086,7 +1086,7 @@ public final SerialPortOutput getSerialPortOutputInstance( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Returns the specified instance's serial port output. + * Returns the last 1 MB of serial port output from the specified instance. * *

Sample code: * @@ -2748,6 +2748,105 @@ public final UnaryCallable setTagsInstanc return stub.setTagsInstanceCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Simulates a maintenance event on the instance. + * + *

Sample code: + * + *


+   * try (InstanceClient instanceClient = InstanceClient.create()) {
+   *   ProjectZoneInstanceName instance = ProjectZoneInstanceName.of("[PROJECT]", "[ZONE]", "[INSTANCE]");
+   *   Operation response = instanceClient.simulateMaintenanceEventInstance(instance);
+   * }
+   * 
+ * + * @param instance Name of the instance scoping this request. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation simulateMaintenanceEventInstance(ProjectZoneInstanceName instance) { + + SimulateMaintenanceEventInstanceHttpRequest request = + SimulateMaintenanceEventInstanceHttpRequest.newBuilder() + .setInstance(instance == null ? null : instance.toString()) + .build(); + return simulateMaintenanceEventInstance(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Simulates a maintenance event on the instance. + * + *

Sample code: + * + *


+   * try (InstanceClient instanceClient = InstanceClient.create()) {
+   *   ProjectZoneInstanceName instance = ProjectZoneInstanceName.of("[PROJECT]", "[ZONE]", "[INSTANCE]");
+   *   Operation response = instanceClient.simulateMaintenanceEventInstance(instance.toString());
+   * }
+   * 
+ * + * @param instance Name of the instance scoping this request. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation simulateMaintenanceEventInstance(String instance) { + + SimulateMaintenanceEventInstanceHttpRequest request = + SimulateMaintenanceEventInstanceHttpRequest.newBuilder().setInstance(instance).build(); + return simulateMaintenanceEventInstance(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Simulates a maintenance event on the instance. + * + *

Sample code: + * + *


+   * try (InstanceClient instanceClient = InstanceClient.create()) {
+   *   ProjectZoneInstanceName instance = ProjectZoneInstanceName.of("[PROJECT]", "[ZONE]", "[INSTANCE]");
+   *   SimulateMaintenanceEventInstanceHttpRequest request = SimulateMaintenanceEventInstanceHttpRequest.newBuilder()
+   *     .setInstance(instance.toString())
+   *     .build();
+   *   Operation response = instanceClient.simulateMaintenanceEventInstance(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation simulateMaintenanceEventInstance( + SimulateMaintenanceEventInstanceHttpRequest request) { + return simulateMaintenanceEventInstanceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Simulates a maintenance event on the instance. + * + *

Sample code: + * + *


+   * try (InstanceClient instanceClient = InstanceClient.create()) {
+   *   ProjectZoneInstanceName instance = ProjectZoneInstanceName.of("[PROJECT]", "[ZONE]", "[INSTANCE]");
+   *   SimulateMaintenanceEventInstanceHttpRequest request = SimulateMaintenanceEventInstanceHttpRequest.newBuilder()
+   *     .setInstance(instance.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = instanceClient.simulateMaintenanceEventInstanceCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + simulateMaintenanceEventInstanceCallable() { + return stub.simulateMaintenanceEventInstanceCallable(); + } + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Starts an instance that was stopped using the instances().stop method. For more information, diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceSettings.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceSettings.java index eb0dc4b8c8c9..7e8d03a8717f 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceSettings.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/InstanceSettings.java @@ -193,6 +193,12 @@ public UnaryCallSettings setTagsInstanceS return ((InstanceStubSettings) getStubSettings()).setTagsInstanceSettings(); } + /** Returns the object with the settings used for calls to simulateMaintenanceEventInstance. */ + public UnaryCallSettings + simulateMaintenanceEventInstanceSettings() { + return ((InstanceStubSettings) getStubSettings()).simulateMaintenanceEventInstanceSettings(); + } + /** Returns the object with the settings used for calls to startInstance. */ public UnaryCallSettings startInstanceSettings() { return ((InstanceStubSettings) getStubSettings()).startInstanceSettings(); @@ -457,6 +463,12 @@ public UnaryCallSettings.Builder resetInsta return getStubSettingsBuilder().setTagsInstanceSettings(); } + /** Returns the builder for the settings used for calls to simulateMaintenanceEventInstance. */ + public UnaryCallSettings.Builder + simulateMaintenanceEventInstanceSettings() { + return getStubSettingsBuilder().simulateMaintenanceEventInstanceSettings(); + } + /** Returns the builder for the settings used for calls to startInstance. */ public UnaryCallSettings.Builder startInstanceSettings() { return getStubSettingsBuilder().startInstanceSettings(); diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/ListSecurityPoliciesHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/ListSecurityPoliciesHttpRequest.java new file mode 100644 index 000000000000..1ace1dc58689 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/ListSecurityPoliciesHttpRequest.java @@ -0,0 +1,509 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class ListSecurityPoliciesHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String filter; + private final String key; + private final Integer maxResults; + private final String orderBy; + private final String pageToken; + private final String prettyPrint; + private final String project; + private final String quotaUser; + private final String userIp; + + private ListSecurityPoliciesHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.filter = null; + this.key = null; + this.maxResults = null; + this.orderBy = null; + this.pageToken = null; + this.prettyPrint = null; + this.project = null; + this.quotaUser = null; + this.userIp = null; + } + + private ListSecurityPoliciesHttpRequest( + String access_token, + String callback, + String fields, + String filter, + String key, + Integer maxResults, + String orderBy, + String pageToken, + String prettyPrint, + String project, + String quotaUser, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.filter = filter; + this.key = key; + this.maxResults = maxResults; + this.orderBy = orderBy; + this.pageToken = pageToken; + this.prettyPrint = prettyPrint; + this.project = project; + this.quotaUser = quotaUser; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("filter")) { + return filter; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("maxResults")) { + return maxResults; + } + if (fieldName.equals("orderBy")) { + return orderBy; + } + if (fieldName.equals("pageToken")) { + return pageToken; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("project")) { + return project; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getFilter() { + return filter; + } + + public String getKey() { + return key; + } + + public Integer getMaxResults() { + return maxResults; + } + + public String getOrderBy() { + return orderBy; + } + + public String getPageToken() { + return pageToken; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public String getProject() { + return project; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(ListSecurityPoliciesHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static ListSecurityPoliciesHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final ListSecurityPoliciesHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new ListSecurityPoliciesHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String filter; + private String key; + private Integer maxResults; + private String orderBy; + private String pageToken; + private String prettyPrint; + private String project; + private String quotaUser; + private String userIp; + + Builder() {} + + public Builder mergeFrom(ListSecurityPoliciesHttpRequest other) { + if (other == ListSecurityPoliciesHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getFilter() != null) { + this.filter = other.filter; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getMaxResults() != null) { + this.maxResults = other.maxResults; + } + if (other.getOrderBy() != null) { + this.orderBy = other.orderBy; + } + if (other.getPageToken() != null) { + this.pageToken = other.pageToken; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getProject() != null) { + this.project = other.project; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(ListSecurityPoliciesHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.filter = source.filter; + this.key = source.key; + this.maxResults = source.maxResults; + this.orderBy = source.orderBy; + this.pageToken = source.pageToken; + this.prettyPrint = source.prettyPrint; + this.project = source.project; + this.quotaUser = source.quotaUser; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getFilter() { + return filter; + } + + public Builder setFilter(String filter) { + this.filter = filter; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public Integer getMaxResults() { + return maxResults; + } + + public Builder setMaxResults(Integer maxResults) { + this.maxResults = maxResults; + return this; + } + + public String getOrderBy() { + return orderBy; + } + + public Builder setOrderBy(String orderBy) { + this.orderBy = orderBy; + return this; + } + + public String getPageToken() { + return pageToken; + } + + public Builder setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public String getProject() { + return project; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public ListSecurityPoliciesHttpRequest build() { + String missing = ""; + + if (project == null) { + missing += " project"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new ListSecurityPoliciesHttpRequest( + access_token, + callback, + fields, + filter, + key, + maxResults, + orderBy, + pageToken, + prettyPrint, + project, + quotaUser, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setFilter(this.filter); + newBuilder.setKey(this.key); + newBuilder.setMaxResults(this.maxResults); + newBuilder.setOrderBy(this.orderBy); + newBuilder.setPageToken(this.pageToken); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setProject(this.project); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "ListSecurityPoliciesHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "filter=" + + filter + + ", " + + "key=" + + key + + ", " + + "maxResults=" + + maxResults + + ", " + + "orderBy=" + + orderBy + + ", " + + "pageToken=" + + pageToken + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "project=" + + project + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof ListSecurityPoliciesHttpRequest) { + ListSecurityPoliciesHttpRequest that = (ListSecurityPoliciesHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.filter, that.getFilter()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.maxResults, that.getMaxResults()) + && Objects.equals(this.orderBy, that.getOrderBy()) + && Objects.equals(this.pageToken, that.getPageToken()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.project, that.getProject()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + callback, + fields, + filter, + key, + maxResults, + orderBy, + pageToken, + prettyPrint, + project, + quotaUser, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/PatchRuleSecurityPolicyHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/PatchRuleSecurityPolicyHttpRequest.java new file mode 100644 index 000000000000..33f98a768827 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/PatchRuleSecurityPolicyHttpRequest.java @@ -0,0 +1,445 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class PatchRuleSecurityPolicyHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String key; + private final String prettyPrint; + private final Integer priority; + private final String quotaUser; + private final String securityPolicy; + private final SecurityPolicyRule securityPolicyRuleResource; + private final String userIp; + + private PatchRuleSecurityPolicyHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.priority = null; + this.quotaUser = null; + this.securityPolicy = null; + this.securityPolicyRuleResource = null; + this.userIp = null; + } + + private PatchRuleSecurityPolicyHttpRequest( + String access_token, + String callback, + String fields, + String key, + String prettyPrint, + Integer priority, + String quotaUser, + String securityPolicy, + SecurityPolicyRule securityPolicyRuleResource, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.priority = priority; + this.quotaUser = quotaUser; + this.securityPolicy = securityPolicy; + this.securityPolicyRuleResource = securityPolicyRuleResource; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("priority")) { + return priority; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } + if (fieldName.equals("securityPolicyRuleResource")) { + return securityPolicyRuleResource; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public SecurityPolicyRule getApiMessageRequestBody() { + return securityPolicyRuleResource; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Integer getPriority() { + return priority; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public SecurityPolicyRule getSecurityPolicyRuleResource() { + return securityPolicyRuleResource; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(PatchRuleSecurityPolicyHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static PatchRuleSecurityPolicyHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final PatchRuleSecurityPolicyHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new PatchRuleSecurityPolicyHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String key; + private String prettyPrint; + private Integer priority; + private String quotaUser; + private String securityPolicy; + private SecurityPolicyRule securityPolicyRuleResource; + private String userIp; + + Builder() {} + + public Builder mergeFrom(PatchRuleSecurityPolicyHttpRequest other) { + if (other == PatchRuleSecurityPolicyHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getPriority() != null) { + this.priority = other.priority; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } + if (other.getSecurityPolicyRuleResource() != null) { + this.securityPolicyRuleResource = other.securityPolicyRuleResource; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(PatchRuleSecurityPolicyHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.priority = source.priority; + this.quotaUser = source.quotaUser; + this.securityPolicy = source.securityPolicy; + this.securityPolicyRuleResource = source.securityPolicyRuleResource; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public Integer getPriority() { + return priority; + } + + public Builder setPriority(Integer priority) { + this.priority = priority; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + public SecurityPolicyRule getSecurityPolicyRuleResource() { + return securityPolicyRuleResource; + } + + public Builder setSecurityPolicyRuleResource(SecurityPolicyRule securityPolicyRuleResource) { + this.securityPolicyRuleResource = securityPolicyRuleResource; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public PatchRuleSecurityPolicyHttpRequest build() { + String missing = ""; + + if (securityPolicy == null) { + missing += " securityPolicy"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new PatchRuleSecurityPolicyHttpRequest( + access_token, + callback, + fields, + key, + prettyPrint, + priority, + quotaUser, + securityPolicy, + securityPolicyRuleResource, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setPriority(this.priority); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setSecurityPolicy(this.securityPolicy); + newBuilder.setSecurityPolicyRuleResource(this.securityPolicyRuleResource); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "PatchRuleSecurityPolicyHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "priority=" + + priority + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "securityPolicy=" + + securityPolicy + + ", " + + "securityPolicyRuleResource=" + + securityPolicyRuleResource + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof PatchRuleSecurityPolicyHttpRequest) { + PatchRuleSecurityPolicyHttpRequest that = (PatchRuleSecurityPolicyHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.priority, that.getPriority()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()) + && Objects.equals(this.securityPolicyRuleResource, that.getSecurityPolicyRuleResource()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + callback, + fields, + key, + prettyPrint, + priority, + quotaUser, + securityPolicy, + securityPolicyRuleResource, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/PatchSecurityPolicyHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/PatchSecurityPolicyHttpRequest.java new file mode 100644 index 000000000000..65cb5625422a --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/PatchSecurityPolicyHttpRequest.java @@ -0,0 +1,487 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class PatchSecurityPolicyHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final List fieldMask; + private final String fields; + private final String key; + private final String prettyPrint; + private final String quotaUser; + private final String requestId; + private final String securityPolicy; + private final SecurityPolicy securityPolicyResource; + private final String userIp; + + private PatchSecurityPolicyHttpRequest() { + this.access_token = null; + this.callback = null; + this.fieldMask = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.quotaUser = null; + this.requestId = null; + this.securityPolicy = null; + this.securityPolicyResource = null; + this.userIp = null; + } + + private PatchSecurityPolicyHttpRequest( + String access_token, + String callback, + List fieldMask, + String fields, + String key, + String prettyPrint, + String quotaUser, + String requestId, + String securityPolicy, + SecurityPolicy securityPolicyResource, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fieldMask = fieldMask; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.quotaUser = quotaUser; + this.requestId = requestId; + this.securityPolicy = securityPolicy; + this.securityPolicyResource = securityPolicyResource; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fieldMask")) { + return fieldMask; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("requestId")) { + return requestId; + } + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } + if (fieldName.equals("securityPolicyResource")) { + return securityPolicyResource; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public SecurityPolicy getApiMessageRequestBody() { + return securityPolicyResource; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public List getFieldMask() { + return fieldMask; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getRequestId() { + return requestId; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public SecurityPolicy getSecurityPolicyResource() { + return securityPolicyResource; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(PatchSecurityPolicyHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static PatchSecurityPolicyHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final PatchSecurityPolicyHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new PatchSecurityPolicyHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private List fieldMask; + private String fields; + private String key; + private String prettyPrint; + private String quotaUser; + private String requestId; + private String securityPolicy; + private SecurityPolicy securityPolicyResource; + private String userIp; + + Builder() {} + + public Builder mergeFrom(PatchSecurityPolicyHttpRequest other) { + if (other == PatchSecurityPolicyHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFieldMask() != null) { + this.fieldMask = other.fieldMask; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getRequestId() != null) { + this.requestId = other.requestId; + } + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } + if (other.getSecurityPolicyResource() != null) { + this.securityPolicyResource = other.securityPolicyResource; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(PatchSecurityPolicyHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fieldMask = source.fieldMask; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.quotaUser = source.quotaUser; + this.requestId = source.requestId; + this.securityPolicy = source.securityPolicy; + this.securityPolicyResource = source.securityPolicyResource; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public List getFieldMask() { + return fieldMask; + } + + public Builder addAllFieldMask(List fieldMask) { + if (this.fieldMask == null) { + this.fieldMask = new LinkedList<>(); + } + this.fieldMask.addAll(fieldMask); + return this; + } + + public Builder addFieldMask(String fieldMask) { + if (this.fieldMask == null) { + this.fieldMask = new LinkedList<>(); + } + this.fieldMask.add(fieldMask); + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getRequestId() { + return requestId; + } + + public Builder setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + public SecurityPolicy getSecurityPolicyResource() { + return securityPolicyResource; + } + + public Builder setSecurityPolicyResource(SecurityPolicy securityPolicyResource) { + this.securityPolicyResource = securityPolicyResource; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public PatchSecurityPolicyHttpRequest build() { + String missing = ""; + + if (fieldMask == null) { + missing += " fieldMask"; + } + + if (securityPolicy == null) { + missing += " securityPolicy"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new PatchSecurityPolicyHttpRequest( + access_token, + callback, + fieldMask, + fields, + key, + prettyPrint, + quotaUser, + requestId, + securityPolicy, + securityPolicyResource, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.addAllFieldMask(this.fieldMask); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setRequestId(this.requestId); + newBuilder.setSecurityPolicy(this.securityPolicy); + newBuilder.setSecurityPolicyResource(this.securityPolicyResource); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "PatchSecurityPolicyHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fieldMask=" + + fieldMask + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "requestId=" + + requestId + + ", " + + "securityPolicy=" + + securityPolicy + + ", " + + "securityPolicyResource=" + + securityPolicyResource + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof PatchSecurityPolicyHttpRequest) { + PatchSecurityPolicyHttpRequest that = (PatchSecurityPolicyHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fieldMask, that.getFieldMask()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.requestId, that.getRequestId()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()) + && Objects.equals(this.securityPolicyResource, that.getSecurityPolicyResource()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + callback, + fieldMask, + fields, + key, + prettyPrint, + quotaUser, + requestId, + securityPolicy, + securityPolicyResource, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/ProjectGlobalSecurityPolicyName.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/ProjectGlobalSecurityPolicyName.java new file mode 100644 index 000000000000..760a06a21db6 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/ProjectGlobalSecurityPolicyName.java @@ -0,0 +1,165 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.api.resourcenames.ResourceNameFactory; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +@Generated("by GAPIC") +@BetaApi +public final class ProjectGlobalSecurityPolicyName implements ResourceName { + private final String project; + private final String securityPolicy; + private static final PathTemplate PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/global/securityPolicies/{securityPolicy}"); + + private volatile Map fieldValuesMap; + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + private ProjectGlobalSecurityPolicyName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + securityPolicy = Preconditions.checkNotNull(builder.getSecurityPolicy()); + } + + public static ProjectGlobalSecurityPolicyName of(String project, String securityPolicy) { + return newBuilder().setProject(project).setSecurityPolicy(securityPolicy).build(); + } + + public static String format(String project, String securityPolicy) { + return of(project, securityPolicy).toString(); + } + + public String getProject() { + return project; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + fieldMapBuilder.put("project", project); + fieldMapBuilder.put("securityPolicy", securityPolicy); + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + public static ResourceNameFactory newFactory() { + return new ResourceNameFactory() { + public ProjectGlobalSecurityPolicyName parse(String formattedString) { + return ProjectGlobalSecurityPolicyName.parse(formattedString); + } + }; + } + + public static ProjectGlobalSecurityPolicyName parse(String formattedString) { + Map matchMap = + PATH_TEMPLATE.validatedMatch( + formattedString, + "ProjectGlobalSecurityPolicyName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("securityPolicy")); + } + + public static boolean isParsableFrom(String formattedString) { + return PATH_TEMPLATE.matches(formattedString); + } + + public static class Builder { + private String project; + private String securityPolicy; + + public String getProject() { + return project; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + private Builder() {} + + public Builder(ProjectGlobalSecurityPolicyName projectGlobalSecurityPolicyName) { + project = projectGlobalSecurityPolicyName.project; + securityPolicy = projectGlobalSecurityPolicyName.securityPolicy; + } + + public ProjectGlobalSecurityPolicyName build() { + return new ProjectGlobalSecurityPolicyName(this); + } + } + + @Override + public String toString() { + return PATH_TEMPLATE.instantiate( + "project", project, + "securityPolicy", securityPolicy); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof ProjectGlobalSecurityPolicyName) { + ProjectGlobalSecurityPolicyName that = (ProjectGlobalSecurityPolicyName) o; + return Objects.equals(this.project, that.getProject()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(project, securityPolicy); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/RemoveRuleSecurityPolicyHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/RemoveRuleSecurityPolicyHttpRequest.java new file mode 100644 index 000000000000..359457f9b38d --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/RemoveRuleSecurityPolicyHttpRequest.java @@ -0,0 +1,413 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class RemoveRuleSecurityPolicyHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String key; + private final String prettyPrint; + private final Integer priority; + private final String quotaUser; + private final String securityPolicy; + private final String userIp; + + private RemoveRuleSecurityPolicyHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.priority = null; + this.quotaUser = null; + this.securityPolicy = null; + this.userIp = null; + } + + private RemoveRuleSecurityPolicyHttpRequest( + String access_token, + String callback, + String fields, + String key, + String prettyPrint, + Integer priority, + String quotaUser, + String securityPolicy, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.priority = priority; + this.quotaUser = quotaUser; + this.securityPolicy = securityPolicy; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("priority")) { + return priority; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Integer getPriority() { + return priority; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(RemoveRuleSecurityPolicyHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static RemoveRuleSecurityPolicyHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final RemoveRuleSecurityPolicyHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new RemoveRuleSecurityPolicyHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String key; + private String prettyPrint; + private Integer priority; + private String quotaUser; + private String securityPolicy; + private String userIp; + + Builder() {} + + public Builder mergeFrom(RemoveRuleSecurityPolicyHttpRequest other) { + if (other == RemoveRuleSecurityPolicyHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getPriority() != null) { + this.priority = other.priority; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(RemoveRuleSecurityPolicyHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.priority = source.priority; + this.quotaUser = source.quotaUser; + this.securityPolicy = source.securityPolicy; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public Integer getPriority() { + return priority; + } + + public Builder setPriority(Integer priority) { + this.priority = priority; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public RemoveRuleSecurityPolicyHttpRequest build() { + String missing = ""; + + if (securityPolicy == null) { + missing += " securityPolicy"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new RemoveRuleSecurityPolicyHttpRequest( + access_token, + callback, + fields, + key, + prettyPrint, + priority, + quotaUser, + securityPolicy, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setPriority(this.priority); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setSecurityPolicy(this.securityPolicy); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "RemoveRuleSecurityPolicyHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "priority=" + + priority + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "securityPolicy=" + + securityPolicy + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof RemoveRuleSecurityPolicyHttpRequest) { + RemoveRuleSecurityPolicyHttpRequest that = (RemoveRuleSecurityPolicyHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.priority, that.getPriority()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.securityPolicy, that.getSecurityPolicy()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + callback, + fields, + key, + prettyPrint, + priority, + quotaUser, + securityPolicy, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicy.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicy.java new file mode 100644 index 000000000000..3ee388993b98 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicy.java @@ -0,0 +1,371 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class SecurityPolicy implements ApiMessage { + private final String creationTimestamp; + private final String description; + private final String fingerprint; + private final String id; + private final String kind; + private final String name; + private final List rules; + private final String selfLink; + + private SecurityPolicy() { + this.creationTimestamp = null; + this.description = null; + this.fingerprint = null; + this.id = null; + this.kind = null; + this.name = null; + this.rules = null; + this.selfLink = null; + } + + private SecurityPolicy( + String creationTimestamp, + String description, + String fingerprint, + String id, + String kind, + String name, + List rules, + String selfLink) { + this.creationTimestamp = creationTimestamp; + this.description = description; + this.fingerprint = fingerprint; + this.id = id; + this.kind = kind; + this.name = name; + this.rules = rules; + this.selfLink = selfLink; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("creationTimestamp")) { + return creationTimestamp; + } + if (fieldName.equals("description")) { + return description; + } + if (fieldName.equals("fingerprint")) { + return fingerprint; + } + if (fieldName.equals("id")) { + return id; + } + if (fieldName.equals("kind")) { + return kind; + } + if (fieldName.equals("name")) { + return name; + } + if (fieldName.equals("rules")) { + return rules; + } + if (fieldName.equals("selfLink")) { + return selfLink; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getCreationTimestamp() { + return creationTimestamp; + } + + public String getDescription() { + return description; + } + + public String getFingerprint() { + return fingerprint; + } + + public String getId() { + return id; + } + + public String getKind() { + return kind; + } + + public String getName() { + return name; + } + + public List getRulesList() { + return rules; + } + + public String getSelfLink() { + return selfLink; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SecurityPolicy prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static SecurityPolicy getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final SecurityPolicy DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SecurityPolicy(); + } + + public static class Builder { + private String creationTimestamp; + private String description; + private String fingerprint; + private String id; + private String kind; + private String name; + private List rules; + private String selfLink; + + Builder() {} + + public Builder mergeFrom(SecurityPolicy other) { + if (other == SecurityPolicy.getDefaultInstance()) return this; + if (other.getCreationTimestamp() != null) { + this.creationTimestamp = other.creationTimestamp; + } + if (other.getDescription() != null) { + this.description = other.description; + } + if (other.getFingerprint() != null) { + this.fingerprint = other.fingerprint; + } + if (other.getId() != null) { + this.id = other.id; + } + if (other.getKind() != null) { + this.kind = other.kind; + } + if (other.getName() != null) { + this.name = other.name; + } + if (other.getRulesList() != null) { + this.rules = other.rules; + } + if (other.getSelfLink() != null) { + this.selfLink = other.selfLink; + } + return this; + } + + Builder(SecurityPolicy source) { + this.creationTimestamp = source.creationTimestamp; + this.description = source.description; + this.fingerprint = source.fingerprint; + this.id = source.id; + this.kind = source.kind; + this.name = source.name; + this.rules = source.rules; + this.selfLink = source.selfLink; + } + + public String getCreationTimestamp() { + return creationTimestamp; + } + + public Builder setCreationTimestamp(String creationTimestamp) { + this.creationTimestamp = creationTimestamp; + return this; + } + + public String getDescription() { + return description; + } + + public Builder setDescription(String description) { + this.description = description; + return this; + } + + public String getFingerprint() { + return fingerprint; + } + + public Builder setFingerprint(String fingerprint) { + this.fingerprint = fingerprint; + return this; + } + + public String getId() { + return id; + } + + public Builder setId(String id) { + this.id = id; + return this; + } + + public String getKind() { + return kind; + } + + public Builder setKind(String kind) { + this.kind = kind; + return this; + } + + public String getName() { + return name; + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public List getRulesList() { + return rules; + } + + public Builder addAllRules(List rules) { + if (this.rules == null) { + this.rules = new LinkedList<>(); + } + this.rules.addAll(rules); + return this; + } + + public Builder addRules(SecurityPolicyRule rules) { + if (this.rules == null) { + this.rules = new LinkedList<>(); + } + this.rules.add(rules); + return this; + } + + public String getSelfLink() { + return selfLink; + } + + public Builder setSelfLink(String selfLink) { + this.selfLink = selfLink; + return this; + } + + public SecurityPolicy build() { + + return new SecurityPolicy( + creationTimestamp, description, fingerprint, id, kind, name, rules, selfLink); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setCreationTimestamp(this.creationTimestamp); + newBuilder.setDescription(this.description); + newBuilder.setFingerprint(this.fingerprint); + newBuilder.setId(this.id); + newBuilder.setKind(this.kind); + newBuilder.setName(this.name); + newBuilder.addAllRules(this.rules); + newBuilder.setSelfLink(this.selfLink); + return newBuilder; + } + } + + @Override + public String toString() { + return "SecurityPolicy{" + + "creationTimestamp=" + + creationTimestamp + + ", " + + "description=" + + description + + ", " + + "fingerprint=" + + fingerprint + + ", " + + "id=" + + id + + ", " + + "kind=" + + kind + + ", " + + "name=" + + name + + ", " + + "rules=" + + rules + + ", " + + "selfLink=" + + selfLink + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof SecurityPolicy) { + SecurityPolicy that = (SecurityPolicy) o; + return Objects.equals(this.creationTimestamp, that.getCreationTimestamp()) + && Objects.equals(this.description, that.getDescription()) + && Objects.equals(this.fingerprint, that.getFingerprint()) + && Objects.equals(this.id, that.getId()) + && Objects.equals(this.kind, that.getKind()) + && Objects.equals(this.name, that.getName()) + && Objects.equals(this.rules, that.getRulesList()) + && Objects.equals(this.selfLink, that.getSelfLink()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + creationTimestamp, description, fingerprint, id, kind, name, rules, selfLink); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyClient.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyClient.java new file mode 100644 index 000000000000..e4846ad62a2b --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyClient.java @@ -0,0 +1,1302 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.compute.v1.stub.SecurityPolicyStub; +import com.google.cloud.compute.v1.stub.SecurityPolicyStubSettings; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: Creates and runs virtual machines on Google Cloud Platform. + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+ *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+ *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+ *   Operation response = securityPolicyClient.addRuleSecurityPolicy(securityPolicy, securityPolicyRuleResource);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the securityPolicyClient object to clean up resources such + * as threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of SecurityPolicySettings to + * create(). For example: + * + *

To customize credentials: + * + *

+ * 
+ * SecurityPolicySettings securityPolicySettings =
+ *     SecurityPolicySettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * SecurityPolicyClient securityPolicyClient =
+ *     SecurityPolicyClient.create(securityPolicySettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * SecurityPolicySettings securityPolicySettings =
+ *     SecurityPolicySettings.newBuilder().setEndpoint(myEndpoint).build();
+ * SecurityPolicyClient securityPolicyClient =
+ *     SecurityPolicyClient.create(securityPolicySettings);
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class SecurityPolicyClient implements BackgroundResource { + private final SecurityPolicySettings settings; + private final SecurityPolicyStub stub; + + /** Constructs an instance of SecurityPolicyClient with default settings. */ + public static final SecurityPolicyClient create() throws IOException { + return create(SecurityPolicySettings.newBuilder().build()); + } + + /** + * Constructs an instance of SecurityPolicyClient, using the given settings. The channels are + * created based on the settings passed in, or defaults for any settings that are not set. + */ + public static final SecurityPolicyClient create(SecurityPolicySettings settings) + throws IOException { + return new SecurityPolicyClient(settings); + } + + /** + * Constructs an instance of SecurityPolicyClient, using the given stub for making calls. This is + * for advanced usage - prefer to use SecurityPolicySettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final SecurityPolicyClient create(SecurityPolicyStub stub) { + return new SecurityPolicyClient(stub); + } + + /** + * Constructs an instance of SecurityPolicyClient, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected SecurityPolicyClient(SecurityPolicySettings settings) throws IOException { + this.settings = settings; + this.stub = ((SecurityPolicyStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected SecurityPolicyClient(SecurityPolicyStub stub) { + this.settings = null; + this.stub = stub; + } + + public final SecurityPolicySettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public SecurityPolicyStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Inserts a rule into a security policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+   *   Operation response = securityPolicyClient.addRuleSecurityPolicy(securityPolicy, securityPolicyRuleResource);
+   * }
+   * 
+ * + * @param securityPolicy Name of the security policy to update. + * @param securityPolicyRuleResource Represents a rule that describes one or more match conditions + * along with the action to be taken when traffic matches this condition (allow or deny). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation addRuleSecurityPolicy( + ProjectGlobalSecurityPolicyName securityPolicy, + SecurityPolicyRule securityPolicyRuleResource) { + + AddRuleSecurityPolicyHttpRequest request = + AddRuleSecurityPolicyHttpRequest.newBuilder() + .setSecurityPolicy(securityPolicy == null ? null : securityPolicy.toString()) + .setSecurityPolicyRuleResource(securityPolicyRuleResource) + .build(); + return addRuleSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Inserts a rule into a security policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+   *   Operation response = securityPolicyClient.addRuleSecurityPolicy(securityPolicy.toString(), securityPolicyRuleResource);
+   * }
+   * 
+ * + * @param securityPolicy Name of the security policy to update. + * @param securityPolicyRuleResource Represents a rule that describes one or more match conditions + * along with the action to be taken when traffic matches this condition (allow or deny). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation addRuleSecurityPolicy( + String securityPolicy, SecurityPolicyRule securityPolicyRuleResource) { + + AddRuleSecurityPolicyHttpRequest request = + AddRuleSecurityPolicyHttpRequest.newBuilder() + .setSecurityPolicy(securityPolicy) + .setSecurityPolicyRuleResource(securityPolicyRuleResource) + .build(); + return addRuleSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Inserts a rule into a security policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+   *   AddRuleSecurityPolicyHttpRequest request = AddRuleSecurityPolicyHttpRequest.newBuilder()
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .setSecurityPolicyRuleResource(securityPolicyRuleResource)
+   *     .build();
+   *   Operation response = securityPolicyClient.addRuleSecurityPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation addRuleSecurityPolicy(AddRuleSecurityPolicyHttpRequest request) { + return addRuleSecurityPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Inserts a rule into a security policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+   *   AddRuleSecurityPolicyHttpRequest request = AddRuleSecurityPolicyHttpRequest.newBuilder()
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .setSecurityPolicyRuleResource(securityPolicyRuleResource)
+   *     .build();
+   *   ApiFuture<Operation> future = securityPolicyClient.addRuleSecurityPolicyCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + addRuleSecurityPolicyCallable() { + return stub.addRuleSecurityPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   Operation response = securityPolicyClient.deleteSecurityPolicy(securityPolicy);
+   * }
+   * 
+ * + * @param securityPolicy Name of the security policy to delete. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation deleteSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy) { + + DeleteSecurityPolicyHttpRequest request = + DeleteSecurityPolicyHttpRequest.newBuilder() + .setSecurityPolicy(securityPolicy == null ? null : securityPolicy.toString()) + .build(); + return deleteSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   Operation response = securityPolicyClient.deleteSecurityPolicy(securityPolicy.toString());
+   * }
+   * 
+ * + * @param securityPolicy Name of the security policy to delete. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation deleteSecurityPolicy(String securityPolicy) { + + DeleteSecurityPolicyHttpRequest request = + DeleteSecurityPolicyHttpRequest.newBuilder().setSecurityPolicy(securityPolicy).build(); + return deleteSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   DeleteSecurityPolicyHttpRequest request = DeleteSecurityPolicyHttpRequest.newBuilder()
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .build();
+   *   Operation response = securityPolicyClient.deleteSecurityPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation deleteSecurityPolicy(DeleteSecurityPolicyHttpRequest request) { + return deleteSecurityPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   DeleteSecurityPolicyHttpRequest request = DeleteSecurityPolicyHttpRequest.newBuilder()
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = securityPolicyClient.deleteSecurityPolicyCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + deleteSecurityPolicyCallable() { + return stub.deleteSecurityPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all of the ordered rules present in a single specified policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicy response = securityPolicyClient.getSecurityPolicy(securityPolicy);
+   * }
+   * 
+ * + * @param securityPolicy Name of the security policy to get. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final SecurityPolicy getSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy) { + + GetSecurityPolicyHttpRequest request = + GetSecurityPolicyHttpRequest.newBuilder() + .setSecurityPolicy(securityPolicy == null ? null : securityPolicy.toString()) + .build(); + return getSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all of the ordered rules present in a single specified policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicy response = securityPolicyClient.getSecurityPolicy(securityPolicy.toString());
+   * }
+   * 
+ * + * @param securityPolicy Name of the security policy to get. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final SecurityPolicy getSecurityPolicy(String securityPolicy) { + + GetSecurityPolicyHttpRequest request = + GetSecurityPolicyHttpRequest.newBuilder().setSecurityPolicy(securityPolicy).build(); + return getSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all of the ordered rules present in a single specified policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   GetSecurityPolicyHttpRequest request = GetSecurityPolicyHttpRequest.newBuilder()
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .build();
+   *   SecurityPolicy response = securityPolicyClient.getSecurityPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final SecurityPolicy getSecurityPolicy(GetSecurityPolicyHttpRequest request) { + return getSecurityPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all of the ordered rules present in a single specified policy. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   GetSecurityPolicyHttpRequest request = GetSecurityPolicyHttpRequest.newBuilder()
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .build();
+   *   ApiFuture<SecurityPolicy> future = securityPolicyClient.getSecurityPolicyCallable().futureCall(request);
+   *   // Do something
+   *   SecurityPolicy response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + getSecurityPolicyCallable() { + return stub.getSecurityPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule response = securityPolicyClient.getRuleSecurityPolicy(priority, securityPolicy);
+   * }
+   * 
+ * + * @param priority The priority of the rule to get from the security policy. + * @param securityPolicy Name of the security policy to which the queried rule belongs. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final SecurityPolicyRule getRuleSecurityPolicy( + Integer priority, ProjectGlobalSecurityPolicyName securityPolicy) { + + GetRuleSecurityPolicyHttpRequest request = + GetRuleSecurityPolicyHttpRequest.newBuilder() + .setPriority(priority) + .setSecurityPolicy(securityPolicy == null ? null : securityPolicy.toString()) + .build(); + return getRuleSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule response = securityPolicyClient.getRuleSecurityPolicy(priority, securityPolicy.toString());
+   * }
+   * 
+ * + * @param priority The priority of the rule to get from the security policy. + * @param securityPolicy Name of the security policy to which the queried rule belongs. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final SecurityPolicyRule getRuleSecurityPolicy(Integer priority, String securityPolicy) { + + GetRuleSecurityPolicyHttpRequest request = + GetRuleSecurityPolicyHttpRequest.newBuilder() + .setPriority(priority) + .setSecurityPolicy(securityPolicy) + .build(); + return getRuleSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   GetRuleSecurityPolicyHttpRequest request = GetRuleSecurityPolicyHttpRequest.newBuilder()
+   *     .setPriority(priority)
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .build();
+   *   SecurityPolicyRule response = securityPolicyClient.getRuleSecurityPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final SecurityPolicyRule getRuleSecurityPolicy(GetRuleSecurityPolicyHttpRequest request) { + return getRuleSecurityPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   GetRuleSecurityPolicyHttpRequest request = GetRuleSecurityPolicyHttpRequest.newBuilder()
+   *     .setPriority(priority)
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .build();
+   *   ApiFuture<SecurityPolicyRule> future = securityPolicyClient.getRuleSecurityPolicyCallable().futureCall(request);
+   *   // Do something
+   *   SecurityPolicyRule response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + getRuleSecurityPolicyCallable() { + return stub.getRuleSecurityPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new policy in the specified project using the data included in the request. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
+   *   Operation response = securityPolicyClient.insertSecurityPolicy(project, securityPolicyResource);
+   * }
+   * 
+ * + * @param project Project ID for this request. + * @param securityPolicyResource A security policy is comprised of one or more rules. It can also + * be associated with one or more 'targets'. (== resource_for v1.securityPolicies ==) (== + * resource_for beta.securityPolicies ==) + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation insertSecurityPolicy( + ProjectName project, SecurityPolicy securityPolicyResource) { + + InsertSecurityPolicyHttpRequest request = + InsertSecurityPolicyHttpRequest.newBuilder() + .setProject(project == null ? null : project.toString()) + .setSecurityPolicyResource(securityPolicyResource) + .build(); + return insertSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new policy in the specified project using the data included in the request. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
+   *   Operation response = securityPolicyClient.insertSecurityPolicy(project.toString(), securityPolicyResource);
+   * }
+   * 
+ * + * @param project Project ID for this request. + * @param securityPolicyResource A security policy is comprised of one or more rules. It can also + * be associated with one or more 'targets'. (== resource_for v1.securityPolicies ==) (== + * resource_for beta.securityPolicies ==) + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation insertSecurityPolicy( + String project, SecurityPolicy securityPolicyResource) { + + InsertSecurityPolicyHttpRequest request = + InsertSecurityPolicyHttpRequest.newBuilder() + .setProject(project) + .setSecurityPolicyResource(securityPolicyResource) + .build(); + return insertSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new policy in the specified project using the data included in the request. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
+   *   InsertSecurityPolicyHttpRequest request = InsertSecurityPolicyHttpRequest.newBuilder()
+   *     .setProject(project.toString())
+   *     .setSecurityPolicyResource(securityPolicyResource)
+   *     .build();
+   *   Operation response = securityPolicyClient.insertSecurityPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation insertSecurityPolicy(InsertSecurityPolicyHttpRequest request) { + return insertSecurityPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a new policy in the specified project using the data included in the request. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
+   *   InsertSecurityPolicyHttpRequest request = InsertSecurityPolicyHttpRequest.newBuilder()
+   *     .setProject(project.toString())
+   *     .setSecurityPolicyResource(securityPolicyResource)
+   *     .build();
+   *   ApiFuture<Operation> future = securityPolicyClient.insertSecurityPolicyCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + insertSecurityPolicyCallable() { + return stub.insertSecurityPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all the policies that have been configured for the specified project. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   for (SecurityPolicy element : securityPolicyClient.listSecurityPolicies(project).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param project Project ID for this request. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final ListSecurityPoliciesPagedResponse listSecurityPolicies(ProjectName project) { + ListSecurityPoliciesHttpRequest request = + ListSecurityPoliciesHttpRequest.newBuilder() + .setProject(project == null ? null : project.toString()) + .build(); + return listSecurityPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all the policies that have been configured for the specified project. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   for (SecurityPolicy element : securityPolicyClient.listSecurityPolicies(project.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param project Project ID for this request. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final ListSecurityPoliciesPagedResponse listSecurityPolicies(String project) { + ListSecurityPoliciesHttpRequest request = + ListSecurityPoliciesHttpRequest.newBuilder().setProject(project).build(); + return listSecurityPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all the policies that have been configured for the specified project. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   ListSecurityPoliciesHttpRequest request = ListSecurityPoliciesHttpRequest.newBuilder()
+   *     .setProject(project.toString())
+   *     .build();
+   *   for (SecurityPolicy element : securityPolicyClient.listSecurityPolicies(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final ListSecurityPoliciesPagedResponse listSecurityPolicies( + ListSecurityPoliciesHttpRequest request) { + return listSecurityPoliciesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all the policies that have been configured for the specified project. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   ListSecurityPoliciesHttpRequest request = ListSecurityPoliciesHttpRequest.newBuilder()
+   *     .setProject(project.toString())
+   *     .build();
+   *   ApiFuture<ListSecurityPoliciesPagedResponse> future = securityPolicyClient.listSecurityPoliciesPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (SecurityPolicy element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + listSecurityPoliciesPagedCallable() { + return stub.listSecurityPoliciesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * List all the policies that have been configured for the specified project. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   ListSecurityPoliciesHttpRequest request = ListSecurityPoliciesHttpRequest.newBuilder()
+   *     .setProject(project.toString())
+   *     .build();
+   *   while (true) {
+   *     SecurityPolicyList response = securityPolicyClient.listSecurityPoliciesCallable().call(request);
+   *     for (SecurityPolicy element : response.getItemsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + listSecurityPoliciesCallable() { + return stub.listSecurityPoliciesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Patches the specified policy with the data included in the request. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
+   *   List<String> fieldMask = new ArrayList<>();
+   *   Operation response = securityPolicyClient.patchSecurityPolicy(securityPolicy, securityPolicyResource, fieldMask);
+   * }
+   * 
+ * + * @param securityPolicy Name of the security policy to update. + * @param securityPolicyResource A security policy is comprised of one or more rules. It can also + * be associated with one or more 'targets'. (== resource_for v1.securityPolicies ==) (== + * resource_for beta.securityPolicies ==) + * @param fieldMask + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation patchSecurityPolicy( + ProjectGlobalSecurityPolicyName securityPolicy, + SecurityPolicy securityPolicyResource, + List fieldMask) { + + PatchSecurityPolicyHttpRequest request = + PatchSecurityPolicyHttpRequest.newBuilder() + .setSecurityPolicy(securityPolicy == null ? null : securityPolicy.toString()) + .setSecurityPolicyResource(securityPolicyResource) + .addAllFieldMask(fieldMask) + .build(); + return patchSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Patches the specified policy with the data included in the request. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
+   *   List<String> fieldMask = new ArrayList<>();
+   *   Operation response = securityPolicyClient.patchSecurityPolicy(securityPolicy.toString(), securityPolicyResource, fieldMask);
+   * }
+   * 
+ * + * @param securityPolicy Name of the security policy to update. + * @param securityPolicyResource A security policy is comprised of one or more rules. It can also + * be associated with one or more 'targets'. (== resource_for v1.securityPolicies ==) (== + * resource_for beta.securityPolicies ==) + * @param fieldMask + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation patchSecurityPolicy( + String securityPolicy, SecurityPolicy securityPolicyResource, List fieldMask) { + + PatchSecurityPolicyHttpRequest request = + PatchSecurityPolicyHttpRequest.newBuilder() + .setSecurityPolicy(securityPolicy) + .setSecurityPolicyResource(securityPolicyResource) + .addAllFieldMask(fieldMask) + .build(); + return patchSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Patches the specified policy with the data included in the request. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
+   *   List<String> fieldMask = new ArrayList<>();
+   *   PatchSecurityPolicyHttpRequest request = PatchSecurityPolicyHttpRequest.newBuilder()
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .setSecurityPolicyResource(securityPolicyResource)
+   *     .addAllFieldMask(fieldMask)
+   *     .build();
+   *   Operation response = securityPolicyClient.patchSecurityPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation patchSecurityPolicy(PatchSecurityPolicyHttpRequest request) { + return patchSecurityPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Patches the specified policy with the data included in the request. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
+   *   List<String> fieldMask = new ArrayList<>();
+   *   PatchSecurityPolicyHttpRequest request = PatchSecurityPolicyHttpRequest.newBuilder()
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .setSecurityPolicyResource(securityPolicyResource)
+   *     .addAllFieldMask(fieldMask)
+   *     .build();
+   *   ApiFuture<Operation> future = securityPolicyClient.patchSecurityPolicyCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + patchSecurityPolicyCallable() { + return stub.patchSecurityPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Patches a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+   *   Operation response = securityPolicyClient.patchRuleSecurityPolicy(priority, securityPolicy, securityPolicyRuleResource);
+   * }
+   * 
+ * + * @param priority The priority of the rule to patch. + * @param securityPolicy Name of the security policy to update. + * @param securityPolicyRuleResource Represents a rule that describes one or more match conditions + * along with the action to be taken when traffic matches this condition (allow or deny). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation patchRuleSecurityPolicy( + Integer priority, + ProjectGlobalSecurityPolicyName securityPolicy, + SecurityPolicyRule securityPolicyRuleResource) { + + PatchRuleSecurityPolicyHttpRequest request = + PatchRuleSecurityPolicyHttpRequest.newBuilder() + .setPriority(priority) + .setSecurityPolicy(securityPolicy == null ? null : securityPolicy.toString()) + .setSecurityPolicyRuleResource(securityPolicyRuleResource) + .build(); + return patchRuleSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Patches a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+   *   Operation response = securityPolicyClient.patchRuleSecurityPolicy(priority, securityPolicy.toString(), securityPolicyRuleResource);
+   * }
+   * 
+ * + * @param priority The priority of the rule to patch. + * @param securityPolicy Name of the security policy to update. + * @param securityPolicyRuleResource Represents a rule that describes one or more match conditions + * along with the action to be taken when traffic matches this condition (allow or deny). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation patchRuleSecurityPolicy( + Integer priority, String securityPolicy, SecurityPolicyRule securityPolicyRuleResource) { + + PatchRuleSecurityPolicyHttpRequest request = + PatchRuleSecurityPolicyHttpRequest.newBuilder() + .setPriority(priority) + .setSecurityPolicy(securityPolicy) + .setSecurityPolicyRuleResource(securityPolicyRuleResource) + .build(); + return patchRuleSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Patches a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+   *   PatchRuleSecurityPolicyHttpRequest request = PatchRuleSecurityPolicyHttpRequest.newBuilder()
+   *     .setPriority(priority)
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .setSecurityPolicyRuleResource(securityPolicyRuleResource)
+   *     .build();
+   *   Operation response = securityPolicyClient.patchRuleSecurityPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation patchRuleSecurityPolicy(PatchRuleSecurityPolicyHttpRequest request) { + return patchRuleSecurityPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Patches a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+   *   PatchRuleSecurityPolicyHttpRequest request = PatchRuleSecurityPolicyHttpRequest.newBuilder()
+   *     .setPriority(priority)
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .setSecurityPolicyRuleResource(securityPolicyRuleResource)
+   *     .build();
+   *   ApiFuture<Operation> future = securityPolicyClient.patchRuleSecurityPolicyCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + patchRuleSecurityPolicyCallable() { + return stub.patchRuleSecurityPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   Operation response = securityPolicyClient.removeRuleSecurityPolicy(priority, securityPolicy);
+   * }
+   * 
+ * + * @param priority The priority of the rule to remove from the security policy. + * @param securityPolicy Name of the security policy to update. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation removeRuleSecurityPolicy( + Integer priority, ProjectGlobalSecurityPolicyName securityPolicy) { + + RemoveRuleSecurityPolicyHttpRequest request = + RemoveRuleSecurityPolicyHttpRequest.newBuilder() + .setPriority(priority) + .setSecurityPolicy(securityPolicy == null ? null : securityPolicy.toString()) + .build(); + return removeRuleSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   Operation response = securityPolicyClient.removeRuleSecurityPolicy(priority, securityPolicy.toString());
+   * }
+   * 
+ * + * @param priority The priority of the rule to remove from the security policy. + * @param securityPolicy Name of the security policy to update. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation removeRuleSecurityPolicy(Integer priority, String securityPolicy) { + + RemoveRuleSecurityPolicyHttpRequest request = + RemoveRuleSecurityPolicyHttpRequest.newBuilder() + .setPriority(priority) + .setSecurityPolicy(securityPolicy) + .build(); + return removeRuleSecurityPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   RemoveRuleSecurityPolicyHttpRequest request = RemoveRuleSecurityPolicyHttpRequest.newBuilder()
+   *     .setPriority(priority)
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .build();
+   *   Operation response = securityPolicyClient.removeRuleSecurityPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi + public final Operation removeRuleSecurityPolicy(RemoveRuleSecurityPolicyHttpRequest request) { + return removeRuleSecurityPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a rule at the specified priority. + * + *

Sample code: + * + *


+   * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+   *   Integer priority = 0;
+   *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+   *   RemoveRuleSecurityPolicyHttpRequest request = RemoveRuleSecurityPolicyHttpRequest.newBuilder()
+   *     .setPriority(priority)
+   *     .setSecurityPolicy(securityPolicy.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = securityPolicyClient.removeRuleSecurityPolicyCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + @BetaApi + public final UnaryCallable + removeRuleSecurityPolicyCallable() { + return stub.removeRuleSecurityPolicyCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListSecurityPoliciesPagedResponse + extends AbstractPagedListResponse< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, SecurityPolicy, + ListSecurityPoliciesPage, ListSecurityPoliciesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListSecurityPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListSecurityPoliciesPagedResponse apply(ListSecurityPoliciesPage input) { + return new ListSecurityPoliciesPagedResponse(input); + } + }); + } + + private ListSecurityPoliciesPagedResponse(ListSecurityPoliciesPage page) { + super(page, ListSecurityPoliciesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListSecurityPoliciesPage + extends AbstractPage< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, SecurityPolicy, + ListSecurityPoliciesPage> { + + private ListSecurityPoliciesPage( + PageContext context, + SecurityPolicyList response) { + super(context, response); + } + + private static ListSecurityPoliciesPage createEmptyPage() { + return new ListSecurityPoliciesPage(null, null); + } + + @Override + protected ListSecurityPoliciesPage createPage( + PageContext context, + SecurityPolicyList response) { + return new ListSecurityPoliciesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListSecurityPoliciesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, SecurityPolicy, + ListSecurityPoliciesPage, ListSecurityPoliciesFixedSizeCollection> { + + private ListSecurityPoliciesFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListSecurityPoliciesFixedSizeCollection createEmptyCollection() { + return new ListSecurityPoliciesFixedSizeCollection(null, 0); + } + + @Override + protected ListSecurityPoliciesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListSecurityPoliciesFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyList.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyList.java new file mode 100644 index 000000000000..45259a2f93a3 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyList.java @@ -0,0 +1,275 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class SecurityPolicyList implements ApiMessage { + private final String id; + private final List items; + private final String kind; + private final String nextPageToken; + private final Warning warning; + + private SecurityPolicyList() { + this.id = null; + this.items = null; + this.kind = null; + this.nextPageToken = null; + this.warning = null; + } + + private SecurityPolicyList( + String id, List items, String kind, String nextPageToken, Warning warning) { + this.id = id; + this.items = items; + this.kind = kind; + this.nextPageToken = nextPageToken; + this.warning = warning; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("id")) { + return id; + } + if (fieldName.equals("items")) { + return items; + } + if (fieldName.equals("kind")) { + return kind; + } + if (fieldName.equals("nextPageToken")) { + return nextPageToken; + } + if (fieldName.equals("warning")) { + return warning; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getId() { + return id; + } + + public List getItemsList() { + return items; + } + + public String getKind() { + return kind; + } + + public String getNextPageToken() { + return nextPageToken; + } + + public Warning getWarning() { + return warning; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SecurityPolicyList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static SecurityPolicyList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final SecurityPolicyList DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SecurityPolicyList(); + } + + public static class Builder { + private String id; + private List items; + private String kind; + private String nextPageToken; + private Warning warning; + + Builder() {} + + public Builder mergeFrom(SecurityPolicyList other) { + if (other == SecurityPolicyList.getDefaultInstance()) return this; + if (other.getId() != null) { + this.id = other.id; + } + if (other.getItemsList() != null) { + this.items = other.items; + } + if (other.getKind() != null) { + this.kind = other.kind; + } + if (other.getNextPageToken() != null) { + this.nextPageToken = other.nextPageToken; + } + if (other.getWarning() != null) { + this.warning = other.warning; + } + return this; + } + + Builder(SecurityPolicyList source) { + this.id = source.id; + this.items = source.items; + this.kind = source.kind; + this.nextPageToken = source.nextPageToken; + this.warning = source.warning; + } + + public String getId() { + return id; + } + + public Builder setId(String id) { + this.id = id; + return this; + } + + public List getItemsList() { + return items; + } + + public Builder addAllItems(List items) { + if (this.items == null) { + this.items = new LinkedList<>(); + } + this.items.addAll(items); + return this; + } + + public Builder addItems(SecurityPolicy items) { + if (this.items == null) { + this.items = new LinkedList<>(); + } + this.items.add(items); + return this; + } + + public String getKind() { + return kind; + } + + public Builder setKind(String kind) { + this.kind = kind; + return this; + } + + public String getNextPageToken() { + return nextPageToken; + } + + public Builder setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + public Warning getWarning() { + return warning; + } + + public Builder setWarning(Warning warning) { + this.warning = warning; + return this; + } + + public SecurityPolicyList build() { + + return new SecurityPolicyList(id, items, kind, nextPageToken, warning); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setId(this.id); + newBuilder.addAllItems(this.items); + newBuilder.setKind(this.kind); + newBuilder.setNextPageToken(this.nextPageToken); + newBuilder.setWarning(this.warning); + return newBuilder; + } + } + + @Override + public String toString() { + return "SecurityPolicyList{" + + "id=" + + id + + ", " + + "items=" + + items + + ", " + + "kind=" + + kind + + ", " + + "nextPageToken=" + + nextPageToken + + ", " + + "warning=" + + warning + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof SecurityPolicyList) { + SecurityPolicyList that = (SecurityPolicyList) o; + return Objects.equals(this.id, that.getId()) + && Objects.equals(this.items, that.getItemsList()) + && Objects.equals(this.kind, that.getKind()) + && Objects.equals(this.nextPageToken, that.getNextPageToken()) + && Objects.equals(this.warning, that.getWarning()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(id, items, kind, nextPageToken, warning); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyReference.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyReference.java new file mode 100644 index 000000000000..bca36f11aa82 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyReference.java @@ -0,0 +1,142 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class SecurityPolicyReference implements ApiMessage { + private final String securityPolicy; + + private SecurityPolicyReference() { + this.securityPolicy = null; + } + + private SecurityPolicyReference(String securityPolicy) { + this.securityPolicy = securityPolicy; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("securityPolicy")) { + return securityPolicy; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SecurityPolicyReference prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static SecurityPolicyReference getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final SecurityPolicyReference DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SecurityPolicyReference(); + } + + public static class Builder { + private String securityPolicy; + + Builder() {} + + public Builder mergeFrom(SecurityPolicyReference other) { + if (other == SecurityPolicyReference.getDefaultInstance()) return this; + if (other.getSecurityPolicy() != null) { + this.securityPolicy = other.securityPolicy; + } + return this; + } + + Builder(SecurityPolicyReference source) { + this.securityPolicy = source.securityPolicy; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public Builder setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + return this; + } + + public SecurityPolicyReference build() { + return new SecurityPolicyReference(securityPolicy); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setSecurityPolicy(this.securityPolicy); + return newBuilder; + } + } + + @Override + public String toString() { + return "SecurityPolicyReference{" + "securityPolicy=" + securityPolicy + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof SecurityPolicyReference) { + SecurityPolicyReference that = (SecurityPolicyReference) o; + return Objects.equals(this.securityPolicy, that.getSecurityPolicy()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(securityPolicy); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRule.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRule.java new file mode 100644 index 000000000000..01fcfa90674c --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRule.java @@ -0,0 +1,297 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class SecurityPolicyRule implements ApiMessage { + private final String action; + private final String description; + private final String kind; + private final SecurityPolicyRuleMatcher match; + private final Boolean preview; + private final Integer priority; + + private SecurityPolicyRule() { + this.action = null; + this.description = null; + this.kind = null; + this.match = null; + this.preview = null; + this.priority = null; + } + + private SecurityPolicyRule( + String action, + String description, + String kind, + SecurityPolicyRuleMatcher match, + Boolean preview, + Integer priority) { + this.action = action; + this.description = description; + this.kind = kind; + this.match = match; + this.preview = preview; + this.priority = priority; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("action")) { + return action; + } + if (fieldName.equals("description")) { + return description; + } + if (fieldName.equals("kind")) { + return kind; + } + if (fieldName.equals("match")) { + return match; + } + if (fieldName.equals("preview")) { + return preview; + } + if (fieldName.equals("priority")) { + return priority; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAction() { + return action; + } + + public String getDescription() { + return description; + } + + public String getKind() { + return kind; + } + + public SecurityPolicyRuleMatcher getMatch() { + return match; + } + + public Boolean getPreview() { + return preview; + } + + public Integer getPriority() { + return priority; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SecurityPolicyRule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static SecurityPolicyRule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final SecurityPolicyRule DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SecurityPolicyRule(); + } + + public static class Builder { + private String action; + private String description; + private String kind; + private SecurityPolicyRuleMatcher match; + private Boolean preview; + private Integer priority; + + Builder() {} + + public Builder mergeFrom(SecurityPolicyRule other) { + if (other == SecurityPolicyRule.getDefaultInstance()) return this; + if (other.getAction() != null) { + this.action = other.action; + } + if (other.getDescription() != null) { + this.description = other.description; + } + if (other.getKind() != null) { + this.kind = other.kind; + } + if (other.getMatch() != null) { + this.match = other.match; + } + if (other.getPreview() != null) { + this.preview = other.preview; + } + if (other.getPriority() != null) { + this.priority = other.priority; + } + return this; + } + + Builder(SecurityPolicyRule source) { + this.action = source.action; + this.description = source.description; + this.kind = source.kind; + this.match = source.match; + this.preview = source.preview; + this.priority = source.priority; + } + + public String getAction() { + return action; + } + + public Builder setAction(String action) { + this.action = action; + return this; + } + + public String getDescription() { + return description; + } + + public Builder setDescription(String description) { + this.description = description; + return this; + } + + public String getKind() { + return kind; + } + + public Builder setKind(String kind) { + this.kind = kind; + return this; + } + + public SecurityPolicyRuleMatcher getMatch() { + return match; + } + + public Builder setMatch(SecurityPolicyRuleMatcher match) { + this.match = match; + return this; + } + + public Boolean getPreview() { + return preview; + } + + public Builder setPreview(Boolean preview) { + this.preview = preview; + return this; + } + + public Integer getPriority() { + return priority; + } + + public Builder setPriority(Integer priority) { + this.priority = priority; + return this; + } + + public SecurityPolicyRule build() { + + return new SecurityPolicyRule(action, description, kind, match, preview, priority); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAction(this.action); + newBuilder.setDescription(this.description); + newBuilder.setKind(this.kind); + newBuilder.setMatch(this.match); + newBuilder.setPreview(this.preview); + newBuilder.setPriority(this.priority); + return newBuilder; + } + } + + @Override + public String toString() { + return "SecurityPolicyRule{" + + "action=" + + action + + ", " + + "description=" + + description + + ", " + + "kind=" + + kind + + ", " + + "match=" + + match + + ", " + + "preview=" + + preview + + ", " + + "priority=" + + priority + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof SecurityPolicyRule) { + SecurityPolicyRule that = (SecurityPolicyRule) o; + return Objects.equals(this.action, that.getAction()) + && Objects.equals(this.description, that.getDescription()) + && Objects.equals(this.kind, that.getKind()) + && Objects.equals(this.match, that.getMatch()) + && Objects.equals(this.preview, that.getPreview()) + && Objects.equals(this.priority, that.getPriority()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(action, description, kind, match, preview, priority); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRuleMatcher.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRuleMatcher.java new file mode 100644 index 000000000000..aef086230258 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRuleMatcher.java @@ -0,0 +1,175 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class SecurityPolicyRuleMatcher implements ApiMessage { + private final SecurityPolicyRuleMatcherConfig config; + private final String versionedExpr; + + private SecurityPolicyRuleMatcher() { + this.config = null; + this.versionedExpr = null; + } + + private SecurityPolicyRuleMatcher(SecurityPolicyRuleMatcherConfig config, String versionedExpr) { + this.config = config; + this.versionedExpr = versionedExpr; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("config")) { + return config; + } + if (fieldName.equals("versionedExpr")) { + return versionedExpr; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public SecurityPolicyRuleMatcherConfig getConfig() { + return config; + } + + public String getVersionedExpr() { + return versionedExpr; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SecurityPolicyRuleMatcher prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static SecurityPolicyRuleMatcher getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final SecurityPolicyRuleMatcher DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SecurityPolicyRuleMatcher(); + } + + public static class Builder { + private SecurityPolicyRuleMatcherConfig config; + private String versionedExpr; + + Builder() {} + + public Builder mergeFrom(SecurityPolicyRuleMatcher other) { + if (other == SecurityPolicyRuleMatcher.getDefaultInstance()) return this; + if (other.getConfig() != null) { + this.config = other.config; + } + if (other.getVersionedExpr() != null) { + this.versionedExpr = other.versionedExpr; + } + return this; + } + + Builder(SecurityPolicyRuleMatcher source) { + this.config = source.config; + this.versionedExpr = source.versionedExpr; + } + + public SecurityPolicyRuleMatcherConfig getConfig() { + return config; + } + + public Builder setConfig(SecurityPolicyRuleMatcherConfig config) { + this.config = config; + return this; + } + + public String getVersionedExpr() { + return versionedExpr; + } + + public Builder setVersionedExpr(String versionedExpr) { + this.versionedExpr = versionedExpr; + return this; + } + + public SecurityPolicyRuleMatcher build() { + + return new SecurityPolicyRuleMatcher(config, versionedExpr); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setConfig(this.config); + newBuilder.setVersionedExpr(this.versionedExpr); + return newBuilder; + } + } + + @Override + public String toString() { + return "SecurityPolicyRuleMatcher{" + + "config=" + + config + + ", " + + "versionedExpr=" + + versionedExpr + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof SecurityPolicyRuleMatcher) { + SecurityPolicyRuleMatcher that = (SecurityPolicyRuleMatcher) o; + return Objects.equals(this.config, that.getConfig()) + && Objects.equals(this.versionedExpr, that.getVersionedExpr()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(config, versionedExpr); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRuleMatcherConfig.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRuleMatcherConfig.java new file mode 100644 index 000000000000..df43c0cd6dff --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicyRuleMatcherConfig.java @@ -0,0 +1,154 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class SecurityPolicyRuleMatcherConfig implements ApiMessage { + private final List srcIpRanges; + + private SecurityPolicyRuleMatcherConfig() { + this.srcIpRanges = null; + } + + private SecurityPolicyRuleMatcherConfig(List srcIpRanges) { + this.srcIpRanges = srcIpRanges; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("srcIpRanges")) { + return srcIpRanges; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public List getSrcIpRangesList() { + return srcIpRanges; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SecurityPolicyRuleMatcherConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static SecurityPolicyRuleMatcherConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final SecurityPolicyRuleMatcherConfig DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SecurityPolicyRuleMatcherConfig(); + } + + public static class Builder { + private List srcIpRanges; + + Builder() {} + + public Builder mergeFrom(SecurityPolicyRuleMatcherConfig other) { + if (other == SecurityPolicyRuleMatcherConfig.getDefaultInstance()) return this; + if (other.getSrcIpRangesList() != null) { + this.srcIpRanges = other.srcIpRanges; + } + return this; + } + + Builder(SecurityPolicyRuleMatcherConfig source) { + this.srcIpRanges = source.srcIpRanges; + } + + public List getSrcIpRangesList() { + return srcIpRanges; + } + + public Builder addAllSrcIpRanges(List srcIpRanges) { + if (this.srcIpRanges == null) { + this.srcIpRanges = new LinkedList<>(); + } + this.srcIpRanges.addAll(srcIpRanges); + return this; + } + + public Builder addSrcIpRanges(String srcIpRanges) { + if (this.srcIpRanges == null) { + this.srcIpRanges = new LinkedList<>(); + } + this.srcIpRanges.add(srcIpRanges); + return this; + } + + public SecurityPolicyRuleMatcherConfig build() { + return new SecurityPolicyRuleMatcherConfig(srcIpRanges); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.addAllSrcIpRanges(this.srcIpRanges); + return newBuilder; + } + } + + @Override + public String toString() { + return "SecurityPolicyRuleMatcherConfig{" + "srcIpRanges=" + srcIpRanges + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof SecurityPolicyRuleMatcherConfig) { + SecurityPolicyRuleMatcherConfig that = (SecurityPolicyRuleMatcherConfig) o; + return Objects.equals(this.srcIpRanges, that.getSrcIpRangesList()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(srcIpRanges); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicySettings.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicySettings.java new file mode 100644 index 000000000000..27d495fecce9 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SecurityPolicySettings.java @@ -0,0 +1,283 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import static com.google.cloud.compute.v1.SecurityPolicyClient.ListSecurityPoliciesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.compute.v1.stub.SecurityPolicyStubSettings; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link SecurityPolicyClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (https://www.googleapis.com/compute/v1/projects/) and default + * port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of addRuleSecurityPolicy to 30 seconds: + * + *

+ * 
+ * SecurityPolicySettings.Builder securityPolicySettingsBuilder =
+ *     SecurityPolicySettings.newBuilder();
+ * securityPolicySettingsBuilder.addRuleSecurityPolicySettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * SecurityPolicySettings securityPolicySettings = securityPolicySettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class SecurityPolicySettings extends ClientSettings { + /** Returns the object with the settings used for calls to addRuleSecurityPolicy. */ + public UnaryCallSettings + addRuleSecurityPolicySettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).addRuleSecurityPolicySettings(); + } + + /** Returns the object with the settings used for calls to deleteSecurityPolicy. */ + public UnaryCallSettings + deleteSecurityPolicySettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).deleteSecurityPolicySettings(); + } + + /** Returns the object with the settings used for calls to getSecurityPolicy. */ + public UnaryCallSettings + getSecurityPolicySettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).getSecurityPolicySettings(); + } + + /** Returns the object with the settings used for calls to getRuleSecurityPolicy. */ + public UnaryCallSettings + getRuleSecurityPolicySettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).getRuleSecurityPolicySettings(); + } + + /** Returns the object with the settings used for calls to insertSecurityPolicy. */ + public UnaryCallSettings + insertSecurityPolicySettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).insertSecurityPolicySettings(); + } + + /** Returns the object with the settings used for calls to listSecurityPolicies. */ + public PagedCallSettings< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, ListSecurityPoliciesPagedResponse> + listSecurityPoliciesSettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).listSecurityPoliciesSettings(); + } + + /** Returns the object with the settings used for calls to patchSecurityPolicy. */ + public UnaryCallSettings + patchSecurityPolicySettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).patchSecurityPolicySettings(); + } + + /** Returns the object with the settings used for calls to patchRuleSecurityPolicy. */ + public UnaryCallSettings + patchRuleSecurityPolicySettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).patchRuleSecurityPolicySettings(); + } + + /** Returns the object with the settings used for calls to removeRuleSecurityPolicy. */ + public UnaryCallSettings + removeRuleSecurityPolicySettings() { + return ((SecurityPolicyStubSettings) getStubSettings()).removeRuleSecurityPolicySettings(); + } + + public static final SecurityPolicySettings create(SecurityPolicyStubSettings stub) + throws IOException { + return new SecurityPolicySettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return SecurityPolicyStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return SecurityPolicyStubSettings.getDefaultEndpoint(); + } + /** Returns the default service port. */ + public static int getDefaultServicePort() { + return SecurityPolicyStubSettings.getDefaultServicePort(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return SecurityPolicyStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return SecurityPolicyStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SecurityPolicyStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return SecurityPolicyStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SecurityPolicyStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected SecurityPolicySettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for SecurityPolicySettings. */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(SecurityPolicyStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(SecurityPolicyStubSettings.newBuilder()); + } + + protected Builder(SecurityPolicySettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(SecurityPolicyStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public SecurityPolicyStubSettings.Builder getStubSettingsBuilder() { + return ((SecurityPolicyStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to addRuleSecurityPolicy. */ + public UnaryCallSettings.Builder + addRuleSecurityPolicySettings() { + return getStubSettingsBuilder().addRuleSecurityPolicySettings(); + } + + /** Returns the builder for the settings used for calls to deleteSecurityPolicy. */ + public UnaryCallSettings.Builder + deleteSecurityPolicySettings() { + return getStubSettingsBuilder().deleteSecurityPolicySettings(); + } + + /** Returns the builder for the settings used for calls to getSecurityPolicy. */ + public UnaryCallSettings.Builder + getSecurityPolicySettings() { + return getStubSettingsBuilder().getSecurityPolicySettings(); + } + + /** Returns the builder for the settings used for calls to getRuleSecurityPolicy. */ + public UnaryCallSettings.Builder + getRuleSecurityPolicySettings() { + return getStubSettingsBuilder().getRuleSecurityPolicySettings(); + } + + /** Returns the builder for the settings used for calls to insertSecurityPolicy. */ + public UnaryCallSettings.Builder + insertSecurityPolicySettings() { + return getStubSettingsBuilder().insertSecurityPolicySettings(); + } + + /** Returns the builder for the settings used for calls to listSecurityPolicies. */ + public PagedCallSettings.Builder< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, ListSecurityPoliciesPagedResponse> + listSecurityPoliciesSettings() { + return getStubSettingsBuilder().listSecurityPoliciesSettings(); + } + + /** Returns the builder for the settings used for calls to patchSecurityPolicy. */ + public UnaryCallSettings.Builder + patchSecurityPolicySettings() { + return getStubSettingsBuilder().patchSecurityPolicySettings(); + } + + /** Returns the builder for the settings used for calls to patchRuleSecurityPolicy. */ + public UnaryCallSettings.Builder + patchRuleSecurityPolicySettings() { + return getStubSettingsBuilder().patchRuleSecurityPolicySettings(); + } + + /** Returns the builder for the settings used for calls to removeRuleSecurityPolicy. */ + public UnaryCallSettings.Builder + removeRuleSecurityPolicySettings() { + return getStubSettingsBuilder().removeRuleSecurityPolicySettings(); + } + + @Override + public SecurityPolicySettings build() throws IOException { + return new SecurityPolicySettings(this); + } + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SetSecurityPolicyBackendServiceHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SetSecurityPolicyBackendServiceHttpRequest.java new file mode 100644 index 000000000000..37d099c1411b --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SetSecurityPolicyBackendServiceHttpRequest.java @@ -0,0 +1,448 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class SetSecurityPolicyBackendServiceHttpRequest implements ApiMessage { + private final String access_token; + private final String backendService; + private final String callback; + private final String fields; + private final String key; + private final String prettyPrint; + private final String quotaUser; + private final String requestId; + private final SecurityPolicyReference securityPolicyReferenceResource; + private final String userIp; + + private SetSecurityPolicyBackendServiceHttpRequest() { + this.access_token = null; + this.backendService = null; + this.callback = null; + this.fields = null; + this.key = null; + this.prettyPrint = null; + this.quotaUser = null; + this.requestId = null; + this.securityPolicyReferenceResource = null; + this.userIp = null; + } + + private SetSecurityPolicyBackendServiceHttpRequest( + String access_token, + String backendService, + String callback, + String fields, + String key, + String prettyPrint, + String quotaUser, + String requestId, + SecurityPolicyReference securityPolicyReferenceResource, + String userIp) { + this.access_token = access_token; + this.backendService = backendService; + this.callback = callback; + this.fields = fields; + this.key = key; + this.prettyPrint = prettyPrint; + this.quotaUser = quotaUser; + this.requestId = requestId; + this.securityPolicyReferenceResource = securityPolicyReferenceResource; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("backendService")) { + return backendService; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("requestId")) { + return requestId; + } + if (fieldName.equals("securityPolicyReferenceResource")) { + return securityPolicyReferenceResource; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public SecurityPolicyReference getApiMessageRequestBody() { + return securityPolicyReferenceResource; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getBackendService() { + return backendService; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getRequestId() { + return requestId; + } + + public SecurityPolicyReference getSecurityPolicyReferenceResource() { + return securityPolicyReferenceResource; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SetSecurityPolicyBackendServiceHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static SetSecurityPolicyBackendServiceHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final SetSecurityPolicyBackendServiceHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SetSecurityPolicyBackendServiceHttpRequest(); + } + + public static class Builder { + private String access_token; + private String backendService; + private String callback; + private String fields; + private String key; + private String prettyPrint; + private String quotaUser; + private String requestId; + private SecurityPolicyReference securityPolicyReferenceResource; + private String userIp; + + Builder() {} + + public Builder mergeFrom(SetSecurityPolicyBackendServiceHttpRequest other) { + if (other == SetSecurityPolicyBackendServiceHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getBackendService() != null) { + this.backendService = other.backendService; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getRequestId() != null) { + this.requestId = other.requestId; + } + if (other.getSecurityPolicyReferenceResource() != null) { + this.securityPolicyReferenceResource = other.securityPolicyReferenceResource; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(SetSecurityPolicyBackendServiceHttpRequest source) { + this.access_token = source.access_token; + this.backendService = source.backendService; + this.callback = source.callback; + this.fields = source.fields; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.quotaUser = source.quotaUser; + this.requestId = source.requestId; + this.securityPolicyReferenceResource = source.securityPolicyReferenceResource; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getBackendService() { + return backendService; + } + + public Builder setBackendService(String backendService) { + this.backendService = backendService; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getRequestId() { + return requestId; + } + + public Builder setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public SecurityPolicyReference getSecurityPolicyReferenceResource() { + return securityPolicyReferenceResource; + } + + public Builder setSecurityPolicyReferenceResource( + SecurityPolicyReference securityPolicyReferenceResource) { + this.securityPolicyReferenceResource = securityPolicyReferenceResource; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public SetSecurityPolicyBackendServiceHttpRequest build() { + String missing = ""; + + if (backendService == null) { + missing += " backendService"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new SetSecurityPolicyBackendServiceHttpRequest( + access_token, + backendService, + callback, + fields, + key, + prettyPrint, + quotaUser, + requestId, + securityPolicyReferenceResource, + userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setBackendService(this.backendService); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setRequestId(this.requestId); + newBuilder.setSecurityPolicyReferenceResource(this.securityPolicyReferenceResource); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "SetSecurityPolicyBackendServiceHttpRequest{" + + "access_token=" + + access_token + + ", " + + "backendService=" + + backendService + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "requestId=" + + requestId + + ", " + + "securityPolicyReferenceResource=" + + securityPolicyReferenceResource + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof SetSecurityPolicyBackendServiceHttpRequest) { + SetSecurityPolicyBackendServiceHttpRequest that = + (SetSecurityPolicyBackendServiceHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.backendService, that.getBackendService()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.requestId, that.getRequestId()) + && Objects.equals( + this.securityPolicyReferenceResource, that.getSecurityPolicyReferenceResource()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, + backendService, + callback, + fields, + key, + prettyPrint, + quotaUser, + requestId, + securityPolicyReferenceResource, + userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SimulateMaintenanceEventInstanceHttpRequest.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SimulateMaintenanceEventInstanceHttpRequest.java new file mode 100644 index 000000000000..e5b6d7614557 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SimulateMaintenanceEventInstanceHttpRequest.java @@ -0,0 +1,368 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.ApiMessage; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +@Generated("by GAPIC") +@BetaApi +public final class SimulateMaintenanceEventInstanceHttpRequest implements ApiMessage { + private final String access_token; + private final String callback; + private final String fields; + private final String instance; + private final String key; + private final String prettyPrint; + private final String quotaUser; + private final String userIp; + + private SimulateMaintenanceEventInstanceHttpRequest() { + this.access_token = null; + this.callback = null; + this.fields = null; + this.instance = null; + this.key = null; + this.prettyPrint = null; + this.quotaUser = null; + this.userIp = null; + } + + private SimulateMaintenanceEventInstanceHttpRequest( + String access_token, + String callback, + String fields, + String instance, + String key, + String prettyPrint, + String quotaUser, + String userIp) { + this.access_token = access_token; + this.callback = callback; + this.fields = fields; + this.instance = instance; + this.key = key; + this.prettyPrint = prettyPrint; + this.quotaUser = quotaUser; + this.userIp = userIp; + } + + @Override + public Object getFieldValue(String fieldName) { + if (fieldName.equals("access_token")) { + return access_token; + } + if (fieldName.equals("callback")) { + return callback; + } + if (fieldName.equals("fields")) { + return fields; + } + if (fieldName.equals("instance")) { + return instance; + } + if (fieldName.equals("key")) { + return key; + } + if (fieldName.equals("prettyPrint")) { + return prettyPrint; + } + if (fieldName.equals("quotaUser")) { + return quotaUser; + } + if (fieldName.equals("userIp")) { + return userIp; + } + return null; + } + + @Nullable + @Override + public ApiMessage getApiMessageRequestBody() { + return null; + } + + @Nullable + @Override + public List getFieldMask() { + return null; + } + + public String getAccessToken() { + return access_token; + } + + public String getCallback() { + return callback; + } + + public String getFields() { + return fields; + } + + public String getInstance() { + return instance; + } + + public String getKey() { + return key; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public String getQuotaUser() { + return quotaUser; + } + + public String getUserIp() { + return userIp; + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(SimulateMaintenanceEventInstanceHttpRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + public static SimulateMaintenanceEventInstanceHttpRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final SimulateMaintenanceEventInstanceHttpRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new SimulateMaintenanceEventInstanceHttpRequest(); + } + + public static class Builder { + private String access_token; + private String callback; + private String fields; + private String instance; + private String key; + private String prettyPrint; + private String quotaUser; + private String userIp; + + Builder() {} + + public Builder mergeFrom(SimulateMaintenanceEventInstanceHttpRequest other) { + if (other == SimulateMaintenanceEventInstanceHttpRequest.getDefaultInstance()) return this; + if (other.getAccessToken() != null) { + this.access_token = other.access_token; + } + if (other.getCallback() != null) { + this.callback = other.callback; + } + if (other.getFields() != null) { + this.fields = other.fields; + } + if (other.getInstance() != null) { + this.instance = other.instance; + } + if (other.getKey() != null) { + this.key = other.key; + } + if (other.getPrettyPrint() != null) { + this.prettyPrint = other.prettyPrint; + } + if (other.getQuotaUser() != null) { + this.quotaUser = other.quotaUser; + } + if (other.getUserIp() != null) { + this.userIp = other.userIp; + } + return this; + } + + Builder(SimulateMaintenanceEventInstanceHttpRequest source) { + this.access_token = source.access_token; + this.callback = source.callback; + this.fields = source.fields; + this.instance = source.instance; + this.key = source.key; + this.prettyPrint = source.prettyPrint; + this.quotaUser = source.quotaUser; + this.userIp = source.userIp; + } + + public String getAccessToken() { + return access_token; + } + + public Builder setAccessToken(String access_token) { + this.access_token = access_token; + return this; + } + + public String getCallback() { + return callback; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public String getFields() { + return fields; + } + + public Builder setFields(String fields) { + this.fields = fields; + return this; + } + + public String getInstance() { + return instance; + } + + public Builder setInstance(String instance) { + this.instance = instance; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + public String getPrettyPrint() { + return prettyPrint; + } + + public Builder setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + return this; + } + + public String getQuotaUser() { + return quotaUser; + } + + public Builder setQuotaUser(String quotaUser) { + this.quotaUser = quotaUser; + return this; + } + + public String getUserIp() { + return userIp; + } + + public Builder setUserIp(String userIp) { + this.userIp = userIp; + return this; + } + + public SimulateMaintenanceEventInstanceHttpRequest build() { + String missing = ""; + + if (instance == null) { + missing += " instance"; + } + + if (!missing.isEmpty()) { + throw new IllegalStateException("Missing required properties:" + missing); + } + return new SimulateMaintenanceEventInstanceHttpRequest( + access_token, callback, fields, instance, key, prettyPrint, quotaUser, userIp); + } + + public Builder clone() { + Builder newBuilder = new Builder(); + newBuilder.setAccessToken(this.access_token); + newBuilder.setCallback(this.callback); + newBuilder.setFields(this.fields); + newBuilder.setInstance(this.instance); + newBuilder.setKey(this.key); + newBuilder.setPrettyPrint(this.prettyPrint); + newBuilder.setQuotaUser(this.quotaUser); + newBuilder.setUserIp(this.userIp); + return newBuilder; + } + } + + @Override + public String toString() { + return "SimulateMaintenanceEventInstanceHttpRequest{" + + "access_token=" + + access_token + + ", " + + "callback=" + + callback + + ", " + + "fields=" + + fields + + ", " + + "instance=" + + instance + + ", " + + "key=" + + key + + ", " + + "prettyPrint=" + + prettyPrint + + ", " + + "quotaUser=" + + quotaUser + + ", " + + "userIp=" + + userIp + + "}"; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof SimulateMaintenanceEventInstanceHttpRequest) { + SimulateMaintenanceEventInstanceHttpRequest that = + (SimulateMaintenanceEventInstanceHttpRequest) o; + return Objects.equals(this.access_token, that.getAccessToken()) + && Objects.equals(this.callback, that.getCallback()) + && Objects.equals(this.fields, that.getFields()) + && Objects.equals(this.instance, that.getInstance()) + && Objects.equals(this.key, that.getKey()) + && Objects.equals(this.prettyPrint, that.getPrettyPrint()) + && Objects.equals(this.quotaUser, that.getQuotaUser()) + && Objects.equals(this.userIp, that.getUserIp()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + access_token, callback, fields, instance, key, prettyPrint, quotaUser, userIp); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/package-info.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/package-info.java index 526f573a0b71..dd17854d59ca 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/package-info.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/package-info.java @@ -662,6 +662,22 @@ * * * + * ==================== SecurityPolicyClient ==================== + * + *

Service Description: Creates and runs virtual machines on Google Cloud Platform. + * + *

Sample for SecurityPolicyClient: + * + *

+ * 
+ * try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
+ *   ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
+ *   SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
+ *   Operation response = securityPolicyClient.addRuleSecurityPolicy(securityPolicy, securityPolicyRuleResource);
+ * }
+ * 
+ * 
+ * * ============== SnapshotClient ============== * *

Service Description: Creates and runs virtual machines on Google Cloud Platform. diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/BackendServiceStub.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/BackendServiceStub.java index 8671c0461a2d..0235ee87d262 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/BackendServiceStub.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/BackendServiceStub.java @@ -35,6 +35,7 @@ import com.google.cloud.compute.v1.ListBackendServicesHttpRequest; import com.google.cloud.compute.v1.Operation; import com.google.cloud.compute.v1.PatchBackendServiceHttpRequest; +import com.google.cloud.compute.v1.SetSecurityPolicyBackendServiceHttpRequest; import com.google.cloud.compute.v1.UpdateBackendServiceHttpRequest; import javax.annotation.Generated; @@ -115,6 +116,13 @@ public UnaryCallable patchBackendServ throw new UnsupportedOperationException("Not implemented: patchBackendServiceCallable()"); } + @BetaApi + public UnaryCallable + setSecurityPolicyBackendServiceCallable() { + throw new UnsupportedOperationException( + "Not implemented: setSecurityPolicyBackendServiceCallable()"); + } + @BetaApi public UnaryCallable updateBackendServiceCallable() { throw new UnsupportedOperationException("Not implemented: updateBackendServiceCallable()"); diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/BackendServiceStubSettings.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/BackendServiceStubSettings.java index 64a41e5d7711..070b57df28c1 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/BackendServiceStubSettings.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/BackendServiceStubSettings.java @@ -55,6 +55,7 @@ import com.google.cloud.compute.v1.ListBackendServicesHttpRequest; import com.google.cloud.compute.v1.Operation; import com.google.cloud.compute.v1.PatchBackendServiceHttpRequest; +import com.google.cloud.compute.v1.SetSecurityPolicyBackendServiceHttpRequest; import com.google.cloud.compute.v1.UpdateBackendServiceHttpRequest; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -127,6 +128,8 @@ public class BackendServiceStubSettings extends StubSettings patchBackendServiceSettings; + private final UnaryCallSettings + setSecurityPolicyBackendServiceSettings; private final UnaryCallSettings updateBackendServiceSettings; @@ -187,6 +190,12 @@ public class BackendServiceStubSettings extends StubSettings + setSecurityPolicyBackendServiceSettings() { + return setSecurityPolicyBackendServiceSettings; + } + /** Returns the object with the settings used for calls to updateBackendService. */ public UnaryCallSettings updateBackendServiceSettings() { @@ -280,6 +289,8 @@ protected BackendServiceStubSettings(Builder settingsBuilder) throws IOException insertBackendServiceSettings = settingsBuilder.insertBackendServiceSettings().build(); listBackendServicesSettings = settingsBuilder.listBackendServicesSettings().build(); patchBackendServiceSettings = settingsBuilder.patchBackendServiceSettings().build(); + setSecurityPolicyBackendServiceSettings = + settingsBuilder.setSecurityPolicyBackendServiceSettings().build(); updateBackendServiceSettings = settingsBuilder.updateBackendServiceSettings().build(); } @@ -443,6 +454,8 @@ public static class Builder extends StubSettings.Builder patchBackendServiceSettings; + private final UnaryCallSettings.Builder + setSecurityPolicyBackendServiceSettings; private final UnaryCallSettings.Builder updateBackendServiceSettings; @@ -507,6 +520,8 @@ protected Builder(ClientContext clientContext) { patchBackendServiceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + setSecurityPolicyBackendServiceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateBackendServiceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = @@ -520,6 +535,7 @@ protected Builder(ClientContext clientContext) { insertBackendServiceSettings, listBackendServicesSettings, patchBackendServiceSettings, + setSecurityPolicyBackendServiceSettings, updateBackendServiceSettings); initDefaults(this); @@ -581,6 +597,11 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + builder + .setSecurityPolicyBackendServiceSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + builder .updateBackendServiceSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) @@ -604,6 +625,8 @@ protected Builder(BackendServiceStubSettings settings) { insertBackendServiceSettings = settings.insertBackendServiceSettings.toBuilder(); listBackendServicesSettings = settings.listBackendServicesSettings.toBuilder(); patchBackendServiceSettings = settings.patchBackendServiceSettings.toBuilder(); + setSecurityPolicyBackendServiceSettings = + settings.setSecurityPolicyBackendServiceSettings.toBuilder(); updateBackendServiceSettings = settings.updateBackendServiceSettings.toBuilder(); unaryMethodSettingsBuilders = @@ -617,6 +640,7 @@ protected Builder(BackendServiceStubSettings settings) { insertBackendServiceSettings, listBackendServicesSettings, patchBackendServiceSettings, + setSecurityPolicyBackendServiceSettings, updateBackendServiceSettings); } @@ -693,6 +717,12 @@ public Builder applyToAllUnaryMethods( return patchBackendServiceSettings; } + /** Returns the builder for the settings used for calls to setSecurityPolicyBackendService. */ + public UnaryCallSettings.Builder + setSecurityPolicyBackendServiceSettings() { + return setSecurityPolicyBackendServiceSettings; + } + /** Returns the builder for the settings used for calls to updateBackendService. */ public UnaryCallSettings.Builder updateBackendServiceSettings() { diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonBackendServiceStub.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonBackendServiceStub.java index 3b6660bcac9f..ed2b73e20203 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonBackendServiceStub.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonBackendServiceStub.java @@ -47,6 +47,7 @@ import com.google.cloud.compute.v1.PatchBackendServiceHttpRequest; import com.google.cloud.compute.v1.ProjectGlobalBackendServiceName; import com.google.cloud.compute.v1.ProjectName; +import com.google.cloud.compute.v1.SetSecurityPolicyBackendServiceHttpRequest; import com.google.cloud.compute.v1.UpdateBackendServiceHttpRequest; import com.google.common.collect.Sets; import java.io.IOException; @@ -251,6 +252,28 @@ public class HttpJsonBackendServiceStub extends BackendServiceStub { .build()) .build(); + @InternalApi + public static final ApiMethodDescriptor + setSecurityPolicyBackendServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.backendServices.setSecurityPolicy") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ApiMessageHttpRequestFormatter + .newBuilder() + .setPathTemplate( + PathTemplate.create( + "{project}/global/backendServices/{backendService}/setSecurityPolicy")) + .setQueryParams(Sets.newHashSet("requestId")) + .setResourceNameFactory(ProjectGlobalBackendServiceName.newFactory()) + .setResourceNameField("backendService") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(Operation.getDefaultInstance()) + .build()) + .build(); + @InternalApi public static final ApiMethodDescriptor updateBackendServiceMethodDescriptor = @@ -297,6 +320,8 @@ public class HttpJsonBackendServiceStub extends BackendServiceStub { listBackendServicesPagedCallable; private final UnaryCallable patchBackendServiceCallable; + private final UnaryCallable + setSecurityPolicyBackendServiceCallable; private final UnaryCallable updateBackendServiceCallable; @@ -390,6 +415,11 @@ protected HttpJsonBackendServiceStub( HttpJsonCallSettings.newBuilder() .setMethodDescriptor(patchBackendServiceMethodDescriptor) .build(); + HttpJsonCallSettings + setSecurityPolicyBackendServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setSecurityPolicyBackendServiceMethodDescriptor) + .build(); HttpJsonCallSettings updateBackendServiceTransportSettings = HttpJsonCallSettings.newBuilder() @@ -451,6 +481,11 @@ protected HttpJsonBackendServiceStub( patchBackendServiceTransportSettings, settings.patchBackendServiceSettings(), clientContext); + this.setSecurityPolicyBackendServiceCallable = + callableFactory.createUnaryCallable( + setSecurityPolicyBackendServiceTransportSettings, + settings.setSecurityPolicyBackendServiceSettings(), + clientContext); this.updateBackendServiceCallable = callableFactory.createUnaryCallable( updateBackendServiceTransportSettings, @@ -523,6 +558,12 @@ public UnaryCallable patchBackendServ return patchBackendServiceCallable; } + @BetaApi + public UnaryCallable + setSecurityPolicyBackendServiceCallable() { + return setSecurityPolicyBackendServiceCallable; + } + @BetaApi public UnaryCallable updateBackendServiceCallable() { return updateBackendServiceCallable; diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonInstanceStub.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonInstanceStub.java index 8ee9c52e86bb..af20d2b8b6c7 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonInstanceStub.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonInstanceStub.java @@ -64,6 +64,7 @@ import com.google.cloud.compute.v1.SetSchedulingInstanceHttpRequest; import com.google.cloud.compute.v1.SetServiceAccountInstanceHttpRequest; import com.google.cloud.compute.v1.SetTagsInstanceHttpRequest; +import com.google.cloud.compute.v1.SimulateMaintenanceEventInstanceHttpRequest; import com.google.cloud.compute.v1.StartInstanceHttpRequest; import com.google.cloud.compute.v1.StartWithEncryptionKeyInstanceHttpRequest; import com.google.cloud.compute.v1.StopInstanceHttpRequest; @@ -547,6 +548,28 @@ public class HttpJsonInstanceStub extends InstanceStub { .build()) .build(); + @InternalApi + public static final ApiMethodDescriptor + simulateMaintenanceEventInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.instances.simulateMaintenanceEvent") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ApiMessageHttpRequestFormatter + .newBuilder() + .setPathTemplate( + PathTemplate.create( + "{project}/zones/{zone}/instances/{instance}/simulateMaintenanceEvent")) + .setQueryParams(Sets.newHashSet()) + .setResourceNameFactory(ProjectZoneInstanceName.newFactory()) + .setResourceNameField("instance") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(Operation.getDefaultInstance()) + .build()) + .build(); + @InternalApi public static final ApiMethodDescriptor startInstanceMethodDescriptor = @@ -697,6 +720,8 @@ public class HttpJsonInstanceStub extends InstanceStub { private final UnaryCallable setServiceAccountInstanceCallable; private final UnaryCallable setTagsInstanceCallable; + private final UnaryCallable + simulateMaintenanceEventInstanceCallable; private final UnaryCallable startInstanceCallable; private final UnaryCallable startWithEncryptionKeyInstanceCallable; @@ -852,6 +877,12 @@ protected HttpJsonInstanceStub( HttpJsonCallSettings.newBuilder() .setMethodDescriptor(setTagsInstanceMethodDescriptor) .build(); + HttpJsonCallSettings + simulateMaintenanceEventInstanceTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(simulateMaintenanceEventInstanceMethodDescriptor) + .build(); HttpJsonCallSettings startInstanceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(startInstanceMethodDescriptor) @@ -987,6 +1018,11 @@ protected HttpJsonInstanceStub( this.setTagsInstanceCallable = callableFactory.createUnaryCallable( setTagsInstanceTransportSettings, settings.setTagsInstanceSettings(), clientContext); + this.simulateMaintenanceEventInstanceCallable = + callableFactory.createUnaryCallable( + simulateMaintenanceEventInstanceTransportSettings, + settings.simulateMaintenanceEventInstanceSettings(), + clientContext); this.startInstanceCallable = callableFactory.createUnaryCallable( startInstanceTransportSettings, settings.startInstanceSettings(), clientContext); @@ -1152,6 +1188,12 @@ public UnaryCallable setTagsInstanceCalla return setTagsInstanceCallable; } + @BetaApi + public UnaryCallable + simulateMaintenanceEventInstanceCallable() { + return simulateMaintenanceEventInstanceCallable; + } + @BetaApi public UnaryCallable startInstanceCallable() { return startInstanceCallable; diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonSecurityPolicyCallableFactory.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonSecurityPolicyCallableFactory.java new file mode 100644 index 000000000000..937100114a71 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonSecurityPolicyCallableFactory.java @@ -0,0 +1,65 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * HTTP callable factory implementation for compute. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class HttpJsonSecurityPolicyCallableFactory implements HttpJsonStubCallableFactory { + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, batchingCallSettings, clientContext); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonSecurityPolicyStub.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonSecurityPolicyStub.java new file mode 100644 index 000000000000..fadbef26d3e2 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/HttpJsonSecurityPolicyStub.java @@ -0,0 +1,494 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1.stub; + +import static com.google.cloud.compute.v1.SecurityPolicyClient.ListSecurityPoliciesPagedResponse; + +import com.google.api.client.http.HttpMethods; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMessageHttpRequestFormatter; +import com.google.api.gax.httpjson.ApiMessageHttpResponseParser; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.cloud.compute.v1.AddRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.DeleteSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.GetRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.GetSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.InsertSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.ListSecurityPoliciesHttpRequest; +import com.google.cloud.compute.v1.Operation; +import com.google.cloud.compute.v1.PatchRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.PatchSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.ProjectGlobalSecurityPolicyName; +import com.google.cloud.compute.v1.ProjectName; +import com.google.cloud.compute.v1.RemoveRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.SecurityPolicy; +import com.google.cloud.compute.v1.SecurityPolicyList; +import com.google.cloud.compute.v1.SecurityPolicyRule; +import com.google.common.collect.Sets; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * HTTP stub implementation for compute. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class HttpJsonSecurityPolicyStub extends SecurityPolicyStub { + @InternalApi + public static final ApiMethodDescriptor + addRuleSecurityPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.addRule") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate( + PathTemplate.create( + "{project}/global/securityPolicies/{securityPolicy}/addRule")) + .setQueryParams(Sets.newHashSet()) + .setResourceNameFactory(ProjectGlobalSecurityPolicyName.newFactory()) + .setResourceNameField("securityPolicy") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(Operation.getDefaultInstance()) + .build()) + .build(); + + @InternalApi + public static final ApiMethodDescriptor + deleteSecurityPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.delete") + .setHttpMethod(HttpMethods.DELETE) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate( + PathTemplate.create("{project}/global/securityPolicies/{securityPolicy}")) + .setQueryParams(Sets.newHashSet("requestId")) + .setResourceNameFactory(ProjectGlobalSecurityPolicyName.newFactory()) + .setResourceNameField("securityPolicy") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(Operation.getDefaultInstance()) + .build()) + .build(); + + @InternalApi + public static final ApiMethodDescriptor + getSecurityPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.get") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate( + PathTemplate.create("{project}/global/securityPolicies/{securityPolicy}")) + .setQueryParams(Sets.newHashSet()) + .setResourceNameFactory(ProjectGlobalSecurityPolicyName.newFactory()) + .setResourceNameField("securityPolicy") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(SecurityPolicy.getDefaultInstance()) + .build()) + .build(); + + @InternalApi + public static final ApiMethodDescriptor + getRuleSecurityPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.getRule") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate( + PathTemplate.create( + "{project}/global/securityPolicies/{securityPolicy}/getRule")) + .setQueryParams(Sets.newHashSet("priority")) + .setResourceNameFactory(ProjectGlobalSecurityPolicyName.newFactory()) + .setResourceNameField("securityPolicy") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(SecurityPolicyRule.getDefaultInstance()) + .build()) + .build(); + + @InternalApi + public static final ApiMethodDescriptor + insertSecurityPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.insert") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate(PathTemplate.create("{project}/global/securityPolicies")) + .setQueryParams(Sets.newHashSet("requestId")) + .setResourceNameFactory(ProjectName.newFactory()) + .setResourceNameField("project") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(Operation.getDefaultInstance()) + .build()) + .build(); + + @InternalApi + public static final ApiMethodDescriptor + listSecurityPoliciesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.list") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate(PathTemplate.create("{project}/global/securityPolicies")) + .setQueryParams( + Sets.newHashSet("filter", "maxResults", "orderBy", "pageToken")) + .setResourceNameFactory(ProjectName.newFactory()) + .setResourceNameField("project") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(SecurityPolicyList.getDefaultInstance()) + .build()) + .build(); + + @InternalApi + public static final ApiMethodDescriptor + patchSecurityPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.patch") + .setHttpMethod(HttpMethods.PATCH) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate( + PathTemplate.create("{project}/global/securityPolicies/{securityPolicy}")) + .setQueryParams(Sets.newHashSet("requestId")) + .setResourceNameFactory(ProjectGlobalSecurityPolicyName.newFactory()) + .setResourceNameField("securityPolicy") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(Operation.getDefaultInstance()) + .build()) + .build(); + + @InternalApi + public static final ApiMethodDescriptor + patchRuleSecurityPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.patchRule") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate( + PathTemplate.create( + "{project}/global/securityPolicies/{securityPolicy}/patchRule")) + .setQueryParams(Sets.newHashSet("priority")) + .setResourceNameFactory(ProjectGlobalSecurityPolicyName.newFactory()) + .setResourceNameField("securityPolicy") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(Operation.getDefaultInstance()) + .build()) + .build(); + + @InternalApi + public static final ApiMethodDescriptor + removeRuleSecurityPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("compute.securityPolicies.removeRule") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ApiMessageHttpRequestFormatter.newBuilder() + .setPathTemplate( + PathTemplate.create( + "{project}/global/securityPolicies/{securityPolicy}/removeRule")) + .setQueryParams(Sets.newHashSet("priority")) + .setResourceNameFactory(ProjectGlobalSecurityPolicyName.newFactory()) + .setResourceNameField("securityPolicy") + .build()) + .setResponseParser( + ApiMessageHttpResponseParser.newBuilder() + .setResponseInstance(Operation.getDefaultInstance()) + .build()) + .build(); + + private final BackgroundResource backgroundResources; + + private final UnaryCallable + addRuleSecurityPolicyCallable; + private final UnaryCallable + deleteSecurityPolicyCallable; + private final UnaryCallable + getSecurityPolicyCallable; + private final UnaryCallable + getRuleSecurityPolicyCallable; + private final UnaryCallable + insertSecurityPolicyCallable; + private final UnaryCallable + listSecurityPoliciesCallable; + private final UnaryCallable + listSecurityPoliciesPagedCallable; + private final UnaryCallable + patchSecurityPolicyCallable; + private final UnaryCallable + patchRuleSecurityPolicyCallable; + private final UnaryCallable + removeRuleSecurityPolicyCallable; + + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSecurityPolicyStub create(SecurityPolicyStubSettings settings) + throws IOException { + return new HttpJsonSecurityPolicyStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSecurityPolicyStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSecurityPolicyStub( + SecurityPolicyStubSettings.newBuilder().build(), clientContext); + } + + public static final HttpJsonSecurityPolicyStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSecurityPolicyStub( + SecurityPolicyStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSecurityPolicyStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonSecurityPolicyStub( + SecurityPolicyStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSecurityPolicyCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSecurityPolicyStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonSecurityPolicyStub( + SecurityPolicyStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + addRuleSecurityPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addRuleSecurityPolicyMethodDescriptor) + .build(); + HttpJsonCallSettings + deleteSecurityPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteSecurityPolicyMethodDescriptor) + .build(); + HttpJsonCallSettings + getSecurityPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSecurityPolicyMethodDescriptor) + .build(); + HttpJsonCallSettings + getRuleSecurityPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRuleSecurityPolicyMethodDescriptor) + .build(); + HttpJsonCallSettings + insertSecurityPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(insertSecurityPolicyMethodDescriptor) + .build(); + HttpJsonCallSettings + listSecurityPoliciesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listSecurityPoliciesMethodDescriptor) + .build(); + HttpJsonCallSettings + patchSecurityPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(patchSecurityPolicyMethodDescriptor) + .build(); + HttpJsonCallSettings + patchRuleSecurityPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(patchRuleSecurityPolicyMethodDescriptor) + .build(); + HttpJsonCallSettings + removeRuleSecurityPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeRuleSecurityPolicyMethodDescriptor) + .build(); + + this.addRuleSecurityPolicyCallable = + callableFactory.createUnaryCallable( + addRuleSecurityPolicyTransportSettings, + settings.addRuleSecurityPolicySettings(), + clientContext); + this.deleteSecurityPolicyCallable = + callableFactory.createUnaryCallable( + deleteSecurityPolicyTransportSettings, + settings.deleteSecurityPolicySettings(), + clientContext); + this.getSecurityPolicyCallable = + callableFactory.createUnaryCallable( + getSecurityPolicyTransportSettings, + settings.getSecurityPolicySettings(), + clientContext); + this.getRuleSecurityPolicyCallable = + callableFactory.createUnaryCallable( + getRuleSecurityPolicyTransportSettings, + settings.getRuleSecurityPolicySettings(), + clientContext); + this.insertSecurityPolicyCallable = + callableFactory.createUnaryCallable( + insertSecurityPolicyTransportSettings, + settings.insertSecurityPolicySettings(), + clientContext); + this.listSecurityPoliciesCallable = + callableFactory.createUnaryCallable( + listSecurityPoliciesTransportSettings, + settings.listSecurityPoliciesSettings(), + clientContext); + this.listSecurityPoliciesPagedCallable = + callableFactory.createPagedCallable( + listSecurityPoliciesTransportSettings, + settings.listSecurityPoliciesSettings(), + clientContext); + this.patchSecurityPolicyCallable = + callableFactory.createUnaryCallable( + patchSecurityPolicyTransportSettings, + settings.patchSecurityPolicySettings(), + clientContext); + this.patchRuleSecurityPolicyCallable = + callableFactory.createUnaryCallable( + patchRuleSecurityPolicyTransportSettings, + settings.patchRuleSecurityPolicySettings(), + clientContext); + this.removeRuleSecurityPolicyCallable = + callableFactory.createUnaryCallable( + removeRuleSecurityPolicyTransportSettings, + settings.removeRuleSecurityPolicySettings(), + clientContext); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @BetaApi + public UnaryCallable + addRuleSecurityPolicyCallable() { + return addRuleSecurityPolicyCallable; + } + + @BetaApi + public UnaryCallable deleteSecurityPolicyCallable() { + return deleteSecurityPolicyCallable; + } + + @BetaApi + public UnaryCallable getSecurityPolicyCallable() { + return getSecurityPolicyCallable; + } + + @BetaApi + public UnaryCallable + getRuleSecurityPolicyCallable() { + return getRuleSecurityPolicyCallable; + } + + @BetaApi + public UnaryCallable insertSecurityPolicyCallable() { + return insertSecurityPolicyCallable; + } + + @BetaApi + public UnaryCallable + listSecurityPoliciesPagedCallable() { + return listSecurityPoliciesPagedCallable; + } + + @BetaApi + public UnaryCallable + listSecurityPoliciesCallable() { + return listSecurityPoliciesCallable; + } + + @BetaApi + public UnaryCallable patchSecurityPolicyCallable() { + return patchSecurityPolicyCallable; + } + + @BetaApi + public UnaryCallable + patchRuleSecurityPolicyCallable() { + return patchRuleSecurityPolicyCallable; + } + + @BetaApi + public UnaryCallable + removeRuleSecurityPolicyCallable() { + return removeRuleSecurityPolicyCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InstanceStub.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InstanceStub.java index 4e10ec10ee86..5b28407e5148 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InstanceStub.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InstanceStub.java @@ -50,6 +50,7 @@ import com.google.cloud.compute.v1.SetSchedulingInstanceHttpRequest; import com.google.cloud.compute.v1.SetServiceAccountInstanceHttpRequest; import com.google.cloud.compute.v1.SetTagsInstanceHttpRequest; +import com.google.cloud.compute.v1.SimulateMaintenanceEventInstanceHttpRequest; import com.google.cloud.compute.v1.StartInstanceHttpRequest; import com.google.cloud.compute.v1.StartWithEncryptionKeyInstanceHttpRequest; import com.google.cloud.compute.v1.StopInstanceHttpRequest; @@ -213,6 +214,13 @@ public UnaryCallable setTagsInstanceCalla throw new UnsupportedOperationException("Not implemented: setTagsInstanceCallable()"); } + @BetaApi + public UnaryCallable + simulateMaintenanceEventInstanceCallable() { + throw new UnsupportedOperationException( + "Not implemented: simulateMaintenanceEventInstanceCallable()"); + } + @BetaApi public UnaryCallable startInstanceCallable() { throw new UnsupportedOperationException("Not implemented: startInstanceCallable()"); diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InstanceStubSettings.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InstanceStubSettings.java index a43e52f1ddf4..c061f6f268ee 100644 --- a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InstanceStubSettings.java +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InstanceStubSettings.java @@ -71,6 +71,7 @@ import com.google.cloud.compute.v1.SetSchedulingInstanceHttpRequest; import com.google.cloud.compute.v1.SetServiceAccountInstanceHttpRequest; import com.google.cloud.compute.v1.SetTagsInstanceHttpRequest; +import com.google.cloud.compute.v1.SimulateMaintenanceEventInstanceHttpRequest; import com.google.cloud.compute.v1.StartInstanceHttpRequest; import com.google.cloud.compute.v1.StartWithEncryptionKeyInstanceHttpRequest; import com.google.cloud.compute.v1.StopInstanceHttpRequest; @@ -170,6 +171,8 @@ public class InstanceStubSettings extends StubSettings { private final UnaryCallSettings setServiceAccountInstanceSettings; private final UnaryCallSettings setTagsInstanceSettings; + private final UnaryCallSettings + simulateMaintenanceEventInstanceSettings; private final UnaryCallSettings startInstanceSettings; private final UnaryCallSettings startWithEncryptionKeyInstanceSettings; @@ -307,6 +310,12 @@ public UnaryCallSettings setTagsInstanceS return setTagsInstanceSettings; } + /** Returns the object with the settings used for calls to simulateMaintenanceEventInstance. */ + public UnaryCallSettings + simulateMaintenanceEventInstanceSettings() { + return simulateMaintenanceEventInstanceSettings; + } + /** Returns the object with the settings used for calls to startInstance. */ public UnaryCallSettings startInstanceSettings() { return startInstanceSettings; @@ -435,6 +444,8 @@ protected InstanceStubSettings(Builder settingsBuilder) throws IOException { setSchedulingInstanceSettings = settingsBuilder.setSchedulingInstanceSettings().build(); setServiceAccountInstanceSettings = settingsBuilder.setServiceAccountInstanceSettings().build(); setTagsInstanceSettings = settingsBuilder.setTagsInstanceSettings().build(); + simulateMaintenanceEventInstanceSettings = + settingsBuilder.simulateMaintenanceEventInstanceSettings().build(); startInstanceSettings = settingsBuilder.startInstanceSettings().build(); startWithEncryptionKeyInstanceSettings = settingsBuilder.startWithEncryptionKeyInstanceSettings().build(); @@ -679,6 +690,8 @@ public static class Builder extends StubSettings.Builder setTagsInstanceSettings; + private final UnaryCallSettings.Builder + simulateMaintenanceEventInstanceSettings; private final UnaryCallSettings.Builder startInstanceSettings; private final UnaryCallSettings.Builder @@ -777,6 +790,8 @@ protected Builder(ClientContext clientContext) { setTagsInstanceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + simulateMaintenanceEventInstanceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + startInstanceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); startWithEncryptionKeyInstanceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); @@ -811,6 +826,7 @@ protected Builder(ClientContext clientContext) { setSchedulingInstanceSettings, setServiceAccountInstanceSettings, setTagsInstanceSettings, + simulateMaintenanceEventInstanceSettings, startInstanceSettings, startWithEncryptionKeyInstanceSettings, stopInstanceSettings, @@ -941,6 +957,11 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + builder + .simulateMaintenanceEventInstanceSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + builder .startInstanceSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) @@ -997,6 +1018,8 @@ protected Builder(InstanceStubSettings settings) { setSchedulingInstanceSettings = settings.setSchedulingInstanceSettings.toBuilder(); setServiceAccountInstanceSettings = settings.setServiceAccountInstanceSettings.toBuilder(); setTagsInstanceSettings = settings.setTagsInstanceSettings.toBuilder(); + simulateMaintenanceEventInstanceSettings = + settings.simulateMaintenanceEventInstanceSettings.toBuilder(); startInstanceSettings = settings.startInstanceSettings.toBuilder(); startWithEncryptionKeyInstanceSettings = settings.startWithEncryptionKeyInstanceSettings.toBuilder(); @@ -1029,6 +1052,7 @@ protected Builder(InstanceStubSettings settings) { setSchedulingInstanceSettings, setServiceAccountInstanceSettings, setTagsInstanceSettings, + simulateMaintenanceEventInstanceSettings, startInstanceSettings, startWithEncryptionKeyInstanceSettings, stopInstanceSettings, @@ -1187,6 +1211,12 @@ public UnaryCallSettings.Builder resetInsta return setTagsInstanceSettings; } + /** Returns the builder for the settings used for calls to simulateMaintenanceEventInstance. */ + public UnaryCallSettings.Builder + simulateMaintenanceEventInstanceSettings() { + return simulateMaintenanceEventInstanceSettings; + } + /** Returns the builder for the settings used for calls to startInstance. */ public UnaryCallSettings.Builder startInstanceSettings() { return startInstanceSettings; diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/SecurityPolicyStub.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/SecurityPolicyStub.java new file mode 100644 index 000000000000..0d05e66228cd --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/SecurityPolicyStub.java @@ -0,0 +1,106 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1.stub; + +import static com.google.cloud.compute.v1.SecurityPolicyClient.ListSecurityPoliciesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.compute.v1.AddRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.DeleteSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.GetRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.GetSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.InsertSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.ListSecurityPoliciesHttpRequest; +import com.google.cloud.compute.v1.Operation; +import com.google.cloud.compute.v1.PatchRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.PatchSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.RemoveRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.SecurityPolicy; +import com.google.cloud.compute.v1.SecurityPolicyList; +import com.google.cloud.compute.v1.SecurityPolicyRule; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for compute. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class SecurityPolicyStub implements BackgroundResource { + + @BetaApi + public UnaryCallable + addRuleSecurityPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: addRuleSecurityPolicyCallable()"); + } + + @BetaApi + public UnaryCallable deleteSecurityPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: deleteSecurityPolicyCallable()"); + } + + @BetaApi + public UnaryCallable getSecurityPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: getSecurityPolicyCallable()"); + } + + @BetaApi + public UnaryCallable + getRuleSecurityPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: getRuleSecurityPolicyCallable()"); + } + + @BetaApi + public UnaryCallable insertSecurityPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: insertSecurityPolicyCallable()"); + } + + @BetaApi + public UnaryCallable + listSecurityPoliciesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listSecurityPoliciesPagedCallable()"); + } + + @BetaApi + public UnaryCallable + listSecurityPoliciesCallable() { + throw new UnsupportedOperationException("Not implemented: listSecurityPoliciesCallable()"); + } + + @BetaApi + public UnaryCallable patchSecurityPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: patchSecurityPolicyCallable()"); + } + + @BetaApi + public UnaryCallable + patchRuleSecurityPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: patchRuleSecurityPolicyCallable()"); + } + + @BetaApi + public UnaryCallable + removeRuleSecurityPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: removeRuleSecurityPolicyCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/SecurityPolicyStubSettings.java b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/SecurityPolicyStubSettings.java new file mode 100644 index 000000000000..1244eca214d6 --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/SecurityPolicyStubSettings.java @@ -0,0 +1,588 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1.stub; + +import static com.google.cloud.compute.v1.SecurityPolicyClient.ListSecurityPoliciesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.compute.v1.AddRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.DeleteSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.GetRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.GetSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.InsertSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.ListSecurityPoliciesHttpRequest; +import com.google.cloud.compute.v1.Operation; +import com.google.cloud.compute.v1.PatchRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.PatchSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.RemoveRuleSecurityPolicyHttpRequest; +import com.google.cloud.compute.v1.SecurityPolicy; +import com.google.cloud.compute.v1.SecurityPolicyList; +import com.google.cloud.compute.v1.SecurityPolicyRule; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link SecurityPolicyStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (https://www.googleapis.com/compute/v1/projects/) and default + * port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of addRuleSecurityPolicy to 30 seconds: + * + *

+ * 
+ * SecurityPolicyStubSettings.Builder securityPolicySettingsBuilder =
+ *     SecurityPolicyStubSettings.newBuilder();
+ * securityPolicySettingsBuilder.addRuleSecurityPolicySettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * SecurityPolicyStubSettings securityPolicySettings = securityPolicySettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class SecurityPolicyStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/cloud-platform") + .add("https://www.googleapis.com/auth/compute") + .add("https://www.googleapis.com/auth/compute.readonly") + .add("https://www.googleapis.com/auth/devstorage.full_control") + .add("https://www.googleapis.com/auth/devstorage.read_only") + .add("https://www.googleapis.com/auth/devstorage.read_write") + .build(); + + private final UnaryCallSettings + addRuleSecurityPolicySettings; + private final UnaryCallSettings + deleteSecurityPolicySettings; + private final UnaryCallSettings + getSecurityPolicySettings; + private final UnaryCallSettings + getRuleSecurityPolicySettings; + private final UnaryCallSettings + insertSecurityPolicySettings; + private final PagedCallSettings< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, ListSecurityPoliciesPagedResponse> + listSecurityPoliciesSettings; + private final UnaryCallSettings + patchSecurityPolicySettings; + private final UnaryCallSettings + patchRuleSecurityPolicySettings; + private final UnaryCallSettings + removeRuleSecurityPolicySettings; + + /** Returns the object with the settings used for calls to addRuleSecurityPolicy. */ + public UnaryCallSettings + addRuleSecurityPolicySettings() { + return addRuleSecurityPolicySettings; + } + + /** Returns the object with the settings used for calls to deleteSecurityPolicy. */ + public UnaryCallSettings + deleteSecurityPolicySettings() { + return deleteSecurityPolicySettings; + } + + /** Returns the object with the settings used for calls to getSecurityPolicy. */ + public UnaryCallSettings + getSecurityPolicySettings() { + return getSecurityPolicySettings; + } + + /** Returns the object with the settings used for calls to getRuleSecurityPolicy. */ + public UnaryCallSettings + getRuleSecurityPolicySettings() { + return getRuleSecurityPolicySettings; + } + + /** Returns the object with the settings used for calls to insertSecurityPolicy. */ + public UnaryCallSettings + insertSecurityPolicySettings() { + return insertSecurityPolicySettings; + } + + /** Returns the object with the settings used for calls to listSecurityPolicies. */ + public PagedCallSettings< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, ListSecurityPoliciesPagedResponse> + listSecurityPoliciesSettings() { + return listSecurityPoliciesSettings; + } + + /** Returns the object with the settings used for calls to patchSecurityPolicy. */ + public UnaryCallSettings + patchSecurityPolicySettings() { + return patchSecurityPolicySettings; + } + + /** Returns the object with the settings used for calls to patchRuleSecurityPolicy. */ + public UnaryCallSettings + patchRuleSecurityPolicySettings() { + return patchRuleSecurityPolicySettings; + } + + /** Returns the object with the settings used for calls to removeRuleSecurityPolicy. */ + public UnaryCallSettings + removeRuleSecurityPolicySettings() { + return removeRuleSecurityPolicySettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public SecurityPolicyStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSecurityPolicyStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "https://www.googleapis.com/compute/v1/projects/"; + } + + /** Returns the default service port. */ + public static int getDefaultServicePort() { + return 443; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultHttpJsonTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SecurityPolicyStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected SecurityPolicyStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + addRuleSecurityPolicySettings = settingsBuilder.addRuleSecurityPolicySettings().build(); + deleteSecurityPolicySettings = settingsBuilder.deleteSecurityPolicySettings().build(); + getSecurityPolicySettings = settingsBuilder.getSecurityPolicySettings().build(); + getRuleSecurityPolicySettings = settingsBuilder.getRuleSecurityPolicySettings().build(); + insertSecurityPolicySettings = settingsBuilder.insertSecurityPolicySettings().build(); + listSecurityPoliciesSettings = settingsBuilder.listSecurityPoliciesSettings().build(); + patchSecurityPolicySettings = settingsBuilder.patchSecurityPolicySettings().build(); + patchRuleSecurityPolicySettings = settingsBuilder.patchRuleSecurityPolicySettings().build(); + removeRuleSecurityPolicySettings = settingsBuilder.removeRuleSecurityPolicySettings().build(); + } + + private static final PagedListDescriptor< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, SecurityPolicy> + LIST_SECURITY_POLICIES_PAGE_STR_DESC = + new PagedListDescriptor< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, SecurityPolicy>() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListSecurityPoliciesHttpRequest injectToken( + ListSecurityPoliciesHttpRequest payload, String token) { + return ListSecurityPoliciesHttpRequest.newBuilder(payload) + .setPageToken(token) + .build(); + } + + @Override + public ListSecurityPoliciesHttpRequest injectPageSize( + ListSecurityPoliciesHttpRequest payload, int pageSize) { + return ListSecurityPoliciesHttpRequest.newBuilder(payload) + .setMaxResults(pageSize) + .build(); + } + + @Override + public Integer extractPageSize(ListSecurityPoliciesHttpRequest payload) { + return payload.getMaxResults(); + } + + @Override + public String extractNextToken(SecurityPolicyList payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(SecurityPolicyList payload) { + return payload.getItemsList(); + } + }; + + private static final PagedListResponseFactory< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, ListSecurityPoliciesPagedResponse> + LIST_SECURITY_POLICIES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, + ListSecurityPoliciesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListSecurityPoliciesHttpRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext + pageContext = + PageContext.create( + callable, LIST_SECURITY_POLICIES_PAGE_STR_DESC, request, context); + return ListSecurityPoliciesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Builder for SecurityPolicyStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final UnaryCallSettings.Builder + addRuleSecurityPolicySettings; + private final UnaryCallSettings.Builder + deleteSecurityPolicySettings; + private final UnaryCallSettings.Builder + getSecurityPolicySettings; + private final UnaryCallSettings.Builder + getRuleSecurityPolicySettings; + private final UnaryCallSettings.Builder + insertSecurityPolicySettings; + private final PagedCallSettings.Builder< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, ListSecurityPoliciesPagedResponse> + listSecurityPoliciesSettings; + private final UnaryCallSettings.Builder + patchSecurityPolicySettings; + private final UnaryCallSettings.Builder + patchRuleSecurityPolicySettings; + private final UnaryCallSettings.Builder + removeRuleSecurityPolicySettings; + + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + addRuleSecurityPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + deleteSecurityPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getSecurityPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getRuleSecurityPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + insertSecurityPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + listSecurityPoliciesSettings = + PagedCallSettings.newBuilder(LIST_SECURITY_POLICIES_PAGE_STR_FACT); + + patchSecurityPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + patchRuleSecurityPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + removeRuleSecurityPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + addRuleSecurityPolicySettings, + deleteSecurityPolicySettings, + getSecurityPolicySettings, + getRuleSecurityPolicySettings, + insertSecurityPolicySettings, + listSecurityPoliciesSettings, + patchSecurityPolicySettings, + patchRuleSecurityPolicySettings, + removeRuleSecurityPolicySettings); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder + .addRuleSecurityPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .deleteSecurityPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .getSecurityPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .getRuleSecurityPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .insertSecurityPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .listSecurityPoliciesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .patchSecurityPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .patchRuleSecurityPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .removeRuleSecurityPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + return builder; + } + + protected Builder(SecurityPolicyStubSettings settings) { + super(settings); + + addRuleSecurityPolicySettings = settings.addRuleSecurityPolicySettings.toBuilder(); + deleteSecurityPolicySettings = settings.deleteSecurityPolicySettings.toBuilder(); + getSecurityPolicySettings = settings.getSecurityPolicySettings.toBuilder(); + getRuleSecurityPolicySettings = settings.getRuleSecurityPolicySettings.toBuilder(); + insertSecurityPolicySettings = settings.insertSecurityPolicySettings.toBuilder(); + listSecurityPoliciesSettings = settings.listSecurityPoliciesSettings.toBuilder(); + patchSecurityPolicySettings = settings.patchSecurityPolicySettings.toBuilder(); + patchRuleSecurityPolicySettings = settings.patchRuleSecurityPolicySettings.toBuilder(); + removeRuleSecurityPolicySettings = settings.removeRuleSecurityPolicySettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + addRuleSecurityPolicySettings, + deleteSecurityPolicySettings, + getSecurityPolicySettings, + getRuleSecurityPolicySettings, + insertSecurityPolicySettings, + listSecurityPoliciesSettings, + patchSecurityPolicySettings, + patchRuleSecurityPolicySettings, + removeRuleSecurityPolicySettings); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to addRuleSecurityPolicy. */ + public UnaryCallSettings.Builder + addRuleSecurityPolicySettings() { + return addRuleSecurityPolicySettings; + } + + /** Returns the builder for the settings used for calls to deleteSecurityPolicy. */ + public UnaryCallSettings.Builder + deleteSecurityPolicySettings() { + return deleteSecurityPolicySettings; + } + + /** Returns the builder for the settings used for calls to getSecurityPolicy. */ + public UnaryCallSettings.Builder + getSecurityPolicySettings() { + return getSecurityPolicySettings; + } + + /** Returns the builder for the settings used for calls to getRuleSecurityPolicy. */ + public UnaryCallSettings.Builder + getRuleSecurityPolicySettings() { + return getRuleSecurityPolicySettings; + } + + /** Returns the builder for the settings used for calls to insertSecurityPolicy. */ + public UnaryCallSettings.Builder + insertSecurityPolicySettings() { + return insertSecurityPolicySettings; + } + + /** Returns the builder for the settings used for calls to listSecurityPolicies. */ + public PagedCallSettings.Builder< + ListSecurityPoliciesHttpRequest, SecurityPolicyList, ListSecurityPoliciesPagedResponse> + listSecurityPoliciesSettings() { + return listSecurityPoliciesSettings; + } + + /** Returns the builder for the settings used for calls to patchSecurityPolicy. */ + public UnaryCallSettings.Builder + patchSecurityPolicySettings() { + return patchSecurityPolicySettings; + } + + /** Returns the builder for the settings used for calls to patchRuleSecurityPolicy. */ + public UnaryCallSettings.Builder + patchRuleSecurityPolicySettings() { + return patchRuleSecurityPolicySettings; + } + + /** Returns the builder for the settings used for calls to removeRuleSecurityPolicy. */ + public UnaryCallSettings.Builder + removeRuleSecurityPolicySettings() { + return removeRuleSecurityPolicySettings; + } + + @Override + public SecurityPolicyStubSettings build() throws IOException { + return new SecurityPolicyStubSettings(this); + } + } +} diff --git a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/BackendServiceClientTest.java b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/BackendServiceClientTest.java index 3f6422644555..5887082b83a3 100644 --- a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/BackendServiceClientTest.java +++ b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/BackendServiceClientTest.java @@ -26,6 +26,7 @@ import static com.google.cloud.compute.v1.stub.HttpJsonBackendServiceStub.insertBackendServiceMethodDescriptor; import static com.google.cloud.compute.v1.stub.HttpJsonBackendServiceStub.listBackendServicesMethodDescriptor; import static com.google.cloud.compute.v1.stub.HttpJsonBackendServiceStub.patchBackendServiceMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonBackendServiceStub.setSecurityPolicyBackendServiceMethodDescriptor; import static com.google.cloud.compute.v1.stub.HttpJsonBackendServiceStub.updateBackendServiceMethodDescriptor; import com.google.api.gax.core.NoCredentialsProvider; @@ -68,6 +69,7 @@ public class BackendServiceClientTest { insertBackendServiceMethodDescriptor, listBackendServicesMethodDescriptor, patchBackendServiceMethodDescriptor, + setSecurityPolicyBackendServiceMethodDescriptor, updateBackendServiceMethodDescriptor)); private static final MockHttpService mockService = new MockHttpService(METHOD_DESCRIPTORS, BackendServiceStubSettings.getDefaultEndpoint()); @@ -445,6 +447,8 @@ public void getBackendServiceTest() { String description = "description-1724546052"; String loadBalancingScheme = "loadBalancingScheme1974502980"; String portName = "portName1115276169"; + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); Integer timeoutSec = 2067488653; String selfLink = "selfLink-1691268851"; String protocol = "protocol-989163880"; @@ -463,6 +467,7 @@ public void getBackendServiceTest() { .setDescription(description) .setLoadBalancingScheme(loadBalancingScheme) .setPortName(portName) + .setSecurityPolicy(securityPolicy.toString()) .setTimeoutSec(timeoutSec) .setSelfLink(selfLink) .setProtocol(protocol) @@ -814,6 +819,101 @@ public void patchBackendServiceExceptionTest() throws Exception { } } + @Test + @SuppressWarnings("all") + public void setSecurityPolicyBackendServiceTest() { + String httpErrorMessage = "httpErrorMessage1276263769"; + String targetId = "targetId-815576439"; + String kind = "kind3292052"; + String description = "description-1724546052"; + String statusMessage = "statusMessage-239442758"; + String selfLink = "selfLink-1691268851"; + String insertTime = "insertTime-103148397"; + Integer httpErrorStatusCode = 1386087020; + ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]"); + String targetLink = "targetLink-2084812312"; + String creationTimestamp = "creationTimestamp567396278"; + String name = "name3373707"; + Integer progress = 1001078227; + String operationType = "operationType-1432962286"; + String startTime = "startTime-1573145462"; + String endTime = "endTime1725551537"; + String id = "id3355"; + ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]"); + String clientOperationId = "clientOperationId-239630617"; + String user = "user3599307"; + String status = "status-892481550"; + Operation expectedResponse = + Operation.newBuilder() + .setHttpErrorMessage(httpErrorMessage) + .setTargetId(targetId) + .setKind(kind) + .setDescription(description) + .setStatusMessage(statusMessage) + .setSelfLink(selfLink) + .setInsertTime(insertTime) + .setHttpErrorStatusCode(httpErrorStatusCode) + .setZone(zone.toString()) + .setTargetLink(targetLink) + .setCreationTimestamp(creationTimestamp) + .setName(name) + .setProgress(progress) + .setOperationType(operationType) + .setStartTime(startTime) + .setEndTime(endTime) + .setId(id) + .setRegion(region.toString()) + .setClientOperationId(clientOperationId) + .setUser(user) + .setStatus(status) + .build(); + mockService.addResponse(expectedResponse); + + ProjectGlobalBackendServiceName backendService = + ProjectGlobalBackendServiceName.of("[PROJECT]", "[BACKEND_SERVICE]"); + SecurityPolicyReference securityPolicyReferenceResource = + SecurityPolicyReference.newBuilder().build(); + + Operation actualResponse = + client.setSecurityPolicyBackendService(backendService, securityPolicyReferenceResource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void setSecurityPolicyBackendServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectGlobalBackendServiceName backendService = + ProjectGlobalBackendServiceName.of("[PROJECT]", "[BACKEND_SERVICE]"); + SecurityPolicyReference securityPolicyReferenceResource = + SecurityPolicyReference.newBuilder().build(); + + client.setSecurityPolicyBackendService(backendService, securityPolicyReferenceResource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + @Test @SuppressWarnings("all") public void updateBackendServiceTest() { diff --git a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/FirewallClientTest.java b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/FirewallClientTest.java index e7983339c088..bc865d8c086e 100644 --- a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/FirewallClientTest.java +++ b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/FirewallClientTest.java @@ -185,6 +185,7 @@ public void getFirewallTest() { String selfLink = "selfLink-1691268851"; String creationTimestamp = "creationTimestamp567396278"; String name = "name3373707"; + Boolean disabled = true; String id = "id3355"; String direction = "direction-962590849"; Firewall expectedResponse = @@ -196,6 +197,7 @@ public void getFirewallTest() { .setSelfLink(selfLink) .setCreationTimestamp(creationTimestamp) .setName(name) + .setDisabled(disabled) .setId(id) .setDirection(direction) .build(); diff --git a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/InstanceClientTest.java b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/InstanceClientTest.java index e278f5d34aa2..c7006223f378 100644 --- a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/InstanceClientTest.java +++ b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/InstanceClientTest.java @@ -40,6 +40,7 @@ import static com.google.cloud.compute.v1.stub.HttpJsonInstanceStub.setSchedulingInstanceMethodDescriptor; import static com.google.cloud.compute.v1.stub.HttpJsonInstanceStub.setServiceAccountInstanceMethodDescriptor; import static com.google.cloud.compute.v1.stub.HttpJsonInstanceStub.setTagsInstanceMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonInstanceStub.simulateMaintenanceEventInstanceMethodDescriptor; import static com.google.cloud.compute.v1.stub.HttpJsonInstanceStub.startInstanceMethodDescriptor; import static com.google.cloud.compute.v1.stub.HttpJsonInstanceStub.startWithEncryptionKeyInstanceMethodDescriptor; import static com.google.cloud.compute.v1.stub.HttpJsonInstanceStub.stopInstanceMethodDescriptor; @@ -99,6 +100,7 @@ public class InstanceClientTest { setSchedulingInstanceMethodDescriptor, setServiceAccountInstanceMethodDescriptor, setTagsInstanceMethodDescriptor, + simulateMaintenanceEventInstanceMethodDescriptor, startInstanceMethodDescriptor, startWithEncryptionKeyInstanceMethodDescriptor, stopInstanceMethodDescriptor, @@ -2045,6 +2047,96 @@ public void setTagsInstanceExceptionTest() throws Exception { } } + @Test + @SuppressWarnings("all") + public void simulateMaintenanceEventInstanceTest() { + String httpErrorMessage = "httpErrorMessage1276263769"; + String targetId = "targetId-815576439"; + String kind = "kind3292052"; + String description = "description-1724546052"; + String statusMessage = "statusMessage-239442758"; + String selfLink = "selfLink-1691268851"; + String insertTime = "insertTime-103148397"; + Integer httpErrorStatusCode = 1386087020; + ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]"); + String targetLink = "targetLink-2084812312"; + String creationTimestamp = "creationTimestamp567396278"; + String name = "name3373707"; + Integer progress = 1001078227; + String operationType = "operationType-1432962286"; + String startTime = "startTime-1573145462"; + String endTime = "endTime1725551537"; + String id = "id3355"; + ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]"); + String clientOperationId = "clientOperationId-239630617"; + String user = "user3599307"; + String status = "status-892481550"; + Operation expectedResponse = + Operation.newBuilder() + .setHttpErrorMessage(httpErrorMessage) + .setTargetId(targetId) + .setKind(kind) + .setDescription(description) + .setStatusMessage(statusMessage) + .setSelfLink(selfLink) + .setInsertTime(insertTime) + .setHttpErrorStatusCode(httpErrorStatusCode) + .setZone(zone.toString()) + .setTargetLink(targetLink) + .setCreationTimestamp(creationTimestamp) + .setName(name) + .setProgress(progress) + .setOperationType(operationType) + .setStartTime(startTime) + .setEndTime(endTime) + .setId(id) + .setRegion(region.toString()) + .setClientOperationId(clientOperationId) + .setUser(user) + .setStatus(status) + .build(); + mockService.addResponse(expectedResponse); + + ProjectZoneInstanceName instance = + ProjectZoneInstanceName.of("[PROJECT]", "[ZONE]", "[INSTANCE]"); + + Operation actualResponse = client.simulateMaintenanceEventInstance(instance); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void simulateMaintenanceEventInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectZoneInstanceName instance = + ProjectZoneInstanceName.of("[PROJECT]", "[ZONE]", "[INSTANCE]"); + + client.simulateMaintenanceEventInstance(instance); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + @Test @SuppressWarnings("all") public void startInstanceTest() { diff --git a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/RegionBackendServiceClientTest.java b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/RegionBackendServiceClientTest.java index 7283c7283635..c6635054771d 100644 --- a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/RegionBackendServiceClientTest.java +++ b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/RegionBackendServiceClientTest.java @@ -189,6 +189,8 @@ public void getRegionBackendServiceTest() { String description = "description-1724546052"; String loadBalancingScheme = "loadBalancingScheme1974502980"; String portName = "portName1115276169"; + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); Integer timeoutSec = 2067488653; String selfLink = "selfLink-1691268851"; String protocol = "protocol-989163880"; @@ -207,6 +209,7 @@ public void getRegionBackendServiceTest() { .setDescription(description) .setLoadBalancingScheme(loadBalancingScheme) .setPortName(portName) + .setSecurityPolicy(securityPolicy.toString()) .setTimeoutSec(timeoutSec) .setSelfLink(selfLink) .setProtocol(protocol) diff --git a/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/SecurityPolicyClientTest.java b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/SecurityPolicyClientTest.java new file mode 100644 index 000000000000..09b62fef485d --- /dev/null +++ b/google-cloud-clients/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/SecurityPolicyClientTest.java @@ -0,0 +1,830 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.compute.v1; + +import static com.google.cloud.compute.v1.SecurityPolicyClient.ListSecurityPoliciesPagedResponse; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.addRuleSecurityPolicyMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.deleteSecurityPolicyMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.getRuleSecurityPolicyMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.getSecurityPolicyMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.insertSecurityPolicyMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.listSecurityPoliciesMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.patchRuleSecurityPolicyMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.patchSecurityPolicyMethodDescriptor; +import static com.google.cloud.compute.v1.stub.HttpJsonSecurityPolicyStub.removeRuleSecurityPolicyMethodDescriptor; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode.Code; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.compute.v1.stub.SecurityPolicyStubSettings; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class SecurityPolicyClientTest { + + private static final List METHOD_DESCRIPTORS = + ImmutableList.copyOf( + Lists.newArrayList( + addRuleSecurityPolicyMethodDescriptor, + deleteSecurityPolicyMethodDescriptor, + getSecurityPolicyMethodDescriptor, + getRuleSecurityPolicyMethodDescriptor, + insertSecurityPolicyMethodDescriptor, + listSecurityPoliciesMethodDescriptor, + patchSecurityPolicyMethodDescriptor, + patchRuleSecurityPolicyMethodDescriptor, + removeRuleSecurityPolicyMethodDescriptor)); + private static final MockHttpService mockService = + new MockHttpService(METHOD_DESCRIPTORS, SecurityPolicyStubSettings.getDefaultEndpoint()); + + private static SecurityPolicyClient client; + private static SecurityPolicySettings clientSettings; + + @BeforeClass + public static void setUp() throws IOException { + clientSettings = + SecurityPolicySettings.newBuilder() + .setTransportChannelProvider( + SecurityPolicySettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SecurityPolicyClient.create(clientSettings); + } + + @After + public void cleanUp() { + mockService.reset(); + } + + @AfterClass + public static void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void addRuleSecurityPolicyTest() { + String httpErrorMessage = "httpErrorMessage1276263769"; + String targetId = "targetId-815576439"; + String kind = "kind3292052"; + String description = "description-1724546052"; + String statusMessage = "statusMessage-239442758"; + String selfLink = "selfLink-1691268851"; + String insertTime = "insertTime-103148397"; + Integer httpErrorStatusCode = 1386087020; + ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]"); + String targetLink = "targetLink-2084812312"; + String creationTimestamp = "creationTimestamp567396278"; + String name = "name3373707"; + Integer progress = 1001078227; + String operationType = "operationType-1432962286"; + String startTime = "startTime-1573145462"; + String endTime = "endTime1725551537"; + String id = "id3355"; + ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]"); + String clientOperationId = "clientOperationId-239630617"; + String user = "user3599307"; + String status = "status-892481550"; + Operation expectedResponse = + Operation.newBuilder() + .setHttpErrorMessage(httpErrorMessage) + .setTargetId(targetId) + .setKind(kind) + .setDescription(description) + .setStatusMessage(statusMessage) + .setSelfLink(selfLink) + .setInsertTime(insertTime) + .setHttpErrorStatusCode(httpErrorStatusCode) + .setZone(zone.toString()) + .setTargetLink(targetLink) + .setCreationTimestamp(creationTimestamp) + .setName(name) + .setProgress(progress) + .setOperationType(operationType) + .setStartTime(startTime) + .setEndTime(endTime) + .setId(id) + .setRegion(region.toString()) + .setClientOperationId(clientOperationId) + .setUser(user) + .setStatus(status) + .build(); + mockService.addResponse(expectedResponse); + + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build(); + + Operation actualResponse = + client.addRuleSecurityPolicy(securityPolicy, securityPolicyRuleResource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void addRuleSecurityPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build(); + + client.addRuleSecurityPolicy(securityPolicy, securityPolicyRuleResource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteSecurityPolicyTest() { + String httpErrorMessage = "httpErrorMessage1276263769"; + String targetId = "targetId-815576439"; + String kind = "kind3292052"; + String description = "description-1724546052"; + String statusMessage = "statusMessage-239442758"; + String selfLink = "selfLink-1691268851"; + String insertTime = "insertTime-103148397"; + Integer httpErrorStatusCode = 1386087020; + ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]"); + String targetLink = "targetLink-2084812312"; + String creationTimestamp = "creationTimestamp567396278"; + String name = "name3373707"; + Integer progress = 1001078227; + String operationType = "operationType-1432962286"; + String startTime = "startTime-1573145462"; + String endTime = "endTime1725551537"; + String id = "id3355"; + ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]"); + String clientOperationId = "clientOperationId-239630617"; + String user = "user3599307"; + String status = "status-892481550"; + Operation expectedResponse = + Operation.newBuilder() + .setHttpErrorMessage(httpErrorMessage) + .setTargetId(targetId) + .setKind(kind) + .setDescription(description) + .setStatusMessage(statusMessage) + .setSelfLink(selfLink) + .setInsertTime(insertTime) + .setHttpErrorStatusCode(httpErrorStatusCode) + .setZone(zone.toString()) + .setTargetLink(targetLink) + .setCreationTimestamp(creationTimestamp) + .setName(name) + .setProgress(progress) + .setOperationType(operationType) + .setStartTime(startTime) + .setEndTime(endTime) + .setId(id) + .setRegion(region.toString()) + .setClientOperationId(clientOperationId) + .setUser(user) + .setStatus(status) + .build(); + mockService.addResponse(expectedResponse); + + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + + Operation actualResponse = client.deleteSecurityPolicy(securityPolicy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void deleteSecurityPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + + client.deleteSecurityPolicy(securityPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getSecurityPolicyTest() { + String kind = "kind3292052"; + String creationTimestamp = "creationTimestamp567396278"; + String fingerprint = "fingerprint-1375934236"; + String name = "name3373707"; + String description = "description-1724546052"; + String id = "id3355"; + String selfLink = "selfLink-1691268851"; + SecurityPolicy expectedResponse = + SecurityPolicy.newBuilder() + .setKind(kind) + .setCreationTimestamp(creationTimestamp) + .setFingerprint(fingerprint) + .setName(name) + .setDescription(description) + .setId(id) + .setSelfLink(selfLink) + .build(); + mockService.addResponse(expectedResponse); + + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + + SecurityPolicy actualResponse = client.getSecurityPolicy(securityPolicy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void getSecurityPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + + client.getSecurityPolicy(securityPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getRuleSecurityPolicyTest() { + Boolean preview = true; + String kind = "kind3292052"; + String action = "action-1422950858"; + String description = "description-1724546052"; + Integer priority2 = 978365527; + SecurityPolicyRule expectedResponse = + SecurityPolicyRule.newBuilder() + .setPreview(preview) + .setKind(kind) + .setAction(action) + .setDescription(description) + .setPriority(priority2) + .build(); + mockService.addResponse(expectedResponse); + + Integer priority = 1165461084; + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + + SecurityPolicyRule actualResponse = client.getRuleSecurityPolicy(priority, securityPolicy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void getRuleSecurityPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Integer priority = 1165461084; + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + + client.getRuleSecurityPolicy(priority, securityPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void insertSecurityPolicyTest() { + String httpErrorMessage = "httpErrorMessage1276263769"; + String targetId = "targetId-815576439"; + String kind = "kind3292052"; + String description = "description-1724546052"; + String statusMessage = "statusMessage-239442758"; + String selfLink = "selfLink-1691268851"; + String insertTime = "insertTime-103148397"; + Integer httpErrorStatusCode = 1386087020; + ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]"); + String targetLink = "targetLink-2084812312"; + String creationTimestamp = "creationTimestamp567396278"; + String name = "name3373707"; + Integer progress = 1001078227; + String operationType = "operationType-1432962286"; + String startTime = "startTime-1573145462"; + String endTime = "endTime1725551537"; + String id = "id3355"; + ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]"); + String clientOperationId = "clientOperationId-239630617"; + String user = "user3599307"; + String status = "status-892481550"; + Operation expectedResponse = + Operation.newBuilder() + .setHttpErrorMessage(httpErrorMessage) + .setTargetId(targetId) + .setKind(kind) + .setDescription(description) + .setStatusMessage(statusMessage) + .setSelfLink(selfLink) + .setInsertTime(insertTime) + .setHttpErrorStatusCode(httpErrorStatusCode) + .setZone(zone.toString()) + .setTargetLink(targetLink) + .setCreationTimestamp(creationTimestamp) + .setName(name) + .setProgress(progress) + .setOperationType(operationType) + .setStartTime(startTime) + .setEndTime(endTime) + .setId(id) + .setRegion(region.toString()) + .setClientOperationId(clientOperationId) + .setUser(user) + .setStatus(status) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName project = ProjectName.of("[PROJECT]"); + SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build(); + + Operation actualResponse = client.insertSecurityPolicy(project, securityPolicyResource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void insertSecurityPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName project = ProjectName.of("[PROJECT]"); + SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build(); + + client.insertSecurityPolicy(project, securityPolicyResource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void listSecurityPoliciesTest() { + String kind = "kind3292052"; + String nextPageToken = ""; + String id = "id3355"; + SecurityPolicy itemsElement = SecurityPolicy.newBuilder().build(); + List items = Arrays.asList(itemsElement); + SecurityPolicyList expectedResponse = + SecurityPolicyList.newBuilder() + .setKind(kind) + .setNextPageToken(nextPageToken) + .setId(id) + .addAllItems(items) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName project = ProjectName.of("[PROJECT]"); + + ListSecurityPoliciesPagedResponse pagedListResponse = client.listSecurityPolicies(project); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void listSecurityPoliciesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName project = ProjectName.of("[PROJECT]"); + + client.listSecurityPolicies(project); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void patchSecurityPolicyTest() { + String httpErrorMessage = "httpErrorMessage1276263769"; + String targetId = "targetId-815576439"; + String kind = "kind3292052"; + String description = "description-1724546052"; + String statusMessage = "statusMessage-239442758"; + String selfLink = "selfLink-1691268851"; + String insertTime = "insertTime-103148397"; + Integer httpErrorStatusCode = 1386087020; + ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]"); + String targetLink = "targetLink-2084812312"; + String creationTimestamp = "creationTimestamp567396278"; + String name = "name3373707"; + Integer progress = 1001078227; + String operationType = "operationType-1432962286"; + String startTime = "startTime-1573145462"; + String endTime = "endTime1725551537"; + String id = "id3355"; + ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]"); + String clientOperationId = "clientOperationId-239630617"; + String user = "user3599307"; + String status = "status-892481550"; + Operation expectedResponse = + Operation.newBuilder() + .setHttpErrorMessage(httpErrorMessage) + .setTargetId(targetId) + .setKind(kind) + .setDescription(description) + .setStatusMessage(statusMessage) + .setSelfLink(selfLink) + .setInsertTime(insertTime) + .setHttpErrorStatusCode(httpErrorStatusCode) + .setZone(zone.toString()) + .setTargetLink(targetLink) + .setCreationTimestamp(creationTimestamp) + .setName(name) + .setProgress(progress) + .setOperationType(operationType) + .setStartTime(startTime) + .setEndTime(endTime) + .setId(id) + .setRegion(region.toString()) + .setClientOperationId(clientOperationId) + .setUser(user) + .setStatus(status) + .build(); + mockService.addResponse(expectedResponse); + + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build(); + List fieldMask = new ArrayList<>(); + + Operation actualResponse = + client.patchSecurityPolicy(securityPolicy, securityPolicyResource, fieldMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void patchSecurityPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build(); + List fieldMask = new ArrayList<>(); + + client.patchSecurityPolicy(securityPolicy, securityPolicyResource, fieldMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void patchRuleSecurityPolicyTest() { + String httpErrorMessage = "httpErrorMessage1276263769"; + String targetId = "targetId-815576439"; + String kind = "kind3292052"; + String description = "description-1724546052"; + String statusMessage = "statusMessage-239442758"; + String selfLink = "selfLink-1691268851"; + String insertTime = "insertTime-103148397"; + Integer httpErrorStatusCode = 1386087020; + ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]"); + String targetLink = "targetLink-2084812312"; + String creationTimestamp = "creationTimestamp567396278"; + String name = "name3373707"; + Integer progress = 1001078227; + String operationType = "operationType-1432962286"; + String startTime = "startTime-1573145462"; + String endTime = "endTime1725551537"; + String id = "id3355"; + ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]"); + String clientOperationId = "clientOperationId-239630617"; + String user = "user3599307"; + String status = "status-892481550"; + Operation expectedResponse = + Operation.newBuilder() + .setHttpErrorMessage(httpErrorMessage) + .setTargetId(targetId) + .setKind(kind) + .setDescription(description) + .setStatusMessage(statusMessage) + .setSelfLink(selfLink) + .setInsertTime(insertTime) + .setHttpErrorStatusCode(httpErrorStatusCode) + .setZone(zone.toString()) + .setTargetLink(targetLink) + .setCreationTimestamp(creationTimestamp) + .setName(name) + .setProgress(progress) + .setOperationType(operationType) + .setStartTime(startTime) + .setEndTime(endTime) + .setId(id) + .setRegion(region.toString()) + .setClientOperationId(clientOperationId) + .setUser(user) + .setStatus(status) + .build(); + mockService.addResponse(expectedResponse); + + Integer priority = 1165461084; + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build(); + + Operation actualResponse = + client.patchRuleSecurityPolicy(priority, securityPolicy, securityPolicyRuleResource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void patchRuleSecurityPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Integer priority = 1165461084; + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build(); + + client.patchRuleSecurityPolicy(priority, securityPolicy, securityPolicyRuleResource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void removeRuleSecurityPolicyTest() { + String httpErrorMessage = "httpErrorMessage1276263769"; + String targetId = "targetId-815576439"; + String kind = "kind3292052"; + String description = "description-1724546052"; + String statusMessage = "statusMessage-239442758"; + String selfLink = "selfLink-1691268851"; + String insertTime = "insertTime-103148397"; + Integer httpErrorStatusCode = 1386087020; + ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]"); + String targetLink = "targetLink-2084812312"; + String creationTimestamp = "creationTimestamp567396278"; + String name = "name3373707"; + Integer progress = 1001078227; + String operationType = "operationType-1432962286"; + String startTime = "startTime-1573145462"; + String endTime = "endTime1725551537"; + String id = "id3355"; + ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]"); + String clientOperationId = "clientOperationId-239630617"; + String user = "user3599307"; + String status = "status-892481550"; + Operation expectedResponse = + Operation.newBuilder() + .setHttpErrorMessage(httpErrorMessage) + .setTargetId(targetId) + .setKind(kind) + .setDescription(description) + .setStatusMessage(statusMessage) + .setSelfLink(selfLink) + .setInsertTime(insertTime) + .setHttpErrorStatusCode(httpErrorStatusCode) + .setZone(zone.toString()) + .setTargetLink(targetLink) + .setCreationTimestamp(creationTimestamp) + .setName(name) + .setProgress(progress) + .setOperationType(operationType) + .setStartTime(startTime) + .setEndTime(endTime) + .setId(id) + .setRegion(region.toString()) + .setClientOperationId(clientOperationId) + .setUser(user) + .setStatus(status) + .build(); + mockService.addResponse(expectedResponse); + + Integer priority = 1165461084; + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + + Operation actualResponse = client.removeRuleSecurityPolicy(priority, securityPolicy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + @SuppressWarnings("all") + public void removeRuleSecurityPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Integer priority = 1165461084; + ProjectGlobalSecurityPolicyName securityPolicy = + ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]"); + + client.removeRuleSecurityPolicy(priority, securityPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } +}