diff --git a/test/integration/BUILD.bazel b/test/integration/BUILD.bazel index 1540d23005..559f9c711c 100644 --- a/test/integration/BUILD.bazel +++ b/test/integration/BUILD.bazel @@ -16,34 +16,30 @@ package(default_visibility = ["//visibility:public"]) # Integration Test Rules #################################################### -integration_test( - name = "redis", - data = ["//test/integration/goldens/redis:goldens_files"], - target = ":redis_java_gapic", -) +INTEGRATION_TEST_LIBRARIES = [ + "asset", + "logging", + "redis", +] -integration_test( - name = "asset", - data = ["//test/integration/goldens/asset:goldens_files"], - target = ":asset_java_gapic", -) +[integration_test( + name = lib_name, + data = ["//test/integration/goldens/%s:goldens_files" % lib_name], + target = ":%s_java_gapic" % lib_name, +) for lib_name in INTEGRATION_TEST_LIBRARIES] -golden_update( - name = "redis_update", - data = ["//test/integration/goldens/redis:goldens_files"], - target = ":redis_java_gapic", -) +[golden_update( + name = "%s_update" % lib_name, + data = ["//test/integration/goldens/%s:goldens_files" % lib_name], + target = ":%s_java_gapic" % lib_name, +) for lib_name in INTEGRATION_TEST_LIBRARIES] -golden_update( - name = "asset_update", - data = ["//test/integration/goldens/asset:goldens_files"], - target = ":asset_java_gapic", -) #################################################### # API Library Rules #################################################### -# These will eventually go away once more APIs in googleapis have been migrated to the microgenerator. +# These will eventually go away once more APIs in googleapis have been migrated to the +# microgenerator. # Asset API. java_gapic_library( @@ -66,12 +62,12 @@ java_gapic_assembly_gradle_pkg( name = "google-cloud-asset-v1-java", deps = [ ":asset_java_gapic", - "@com_google_googleapis//google/cloud/orgpolicy/v1:orgpolicy_java_proto", "@com_google_googleapis//google/cloud/asset/v1:asset_java_grpc", - "@com_google_googleapis//google/identity/accesscontextmanager/type:type_java_proto", - "@com_google_googleapis//google/identity/accesscontextmanager/v1:accesscontextmanager_java_proto", "@com_google_googleapis//google/cloud/asset/v1:asset_java_proto", "@com_google_googleapis//google/cloud/asset/v1:asset_proto", + "@com_google_googleapis//google/cloud/orgpolicy/v1:orgpolicy_java_proto", + "@com_google_googleapis//google/identity/accesscontextmanager/type:type_java_proto", + "@com_google_googleapis//google/identity/accesscontextmanager/v1:accesscontextmanager_java_proto", ], ) diff --git a/test/integration/goldens/logging/BUILD.bazel b/test/integration/goldens/logging/BUILD.bazel new file mode 100644 index 0000000000..0b74aed56b --- /dev/null +++ b/test/integration/goldens/logging/BUILD.bazel @@ -0,0 +1,6 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "goldens_files", + srcs = glob(["*.java"]), +) diff --git a/test/integration/goldens/logging/BillingAccountLocationName.java b/test/integration/goldens/logging/BillingAccountLocationName.java new file mode 100644 index 0000000000..3d108a3a4b --- /dev/null +++ b/test/integration/goldens/logging/BillingAccountLocationName.java @@ -0,0 +1,188 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class BillingAccountLocationName implements ResourceName { + private static final PathTemplate BILLING_ACCOUNT_LOCATION = + PathTemplate.createWithoutUrlEncoding( + "billingAccounts/{billing_account}/locations/{location}"); + private volatile Map fieldValuesMap; + private final String billingAccount; + private final String location; + + private BillingAccountLocationName(Builder builder) { + billingAccount = Preconditions.checkNotNull(builder.getBillingAccount()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + + public String getBillingAccount() { + return billingAccount; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static BillingAccountLocationName of(String billingAccount, String location) { + return newBuilder().setBillingAccount(billingAccount).setLocation(location).build(); + } + + public static String format(String billingAccount, String location) { + return newBuilder().setBillingAccount(billingAccount).setLocation(location).build().toString(); + } + + public static BillingAccountLocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + BILLING_ACCOUNT_LOCATION.validatedMatch( + formattedString, + "BillingAccountLocationName.parse: formattedString not in valid format"); + return of(matchMap.get("billing_account"), matchMap.get("location")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (BillingAccountLocationName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return BILLING_ACCOUNT_LOCATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(billingAccount)) { + fieldMapBuilder.put("billing_account", billingAccount); + } + if (!Objects.isNull(location)) { + fieldMapBuilder.put("location", location); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return BILLING_ACCOUNT_LOCATION.instantiate("billing_account", billingAccount); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + BillingAccountLocationName that = ((BillingAccountLocationName) o); + return Objects.equals(this.billingAccount, that.billingAccount) + && Objects.equals(this.location, that.location); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(billingAccount); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for billingAccounts/{billing_account}/locations/{location}. */ + public static class Builder { + private String billingAccount; + private String location; + + private Builder() {} + + public String getBillingAccount() { + return billingAccount; + } + + public String getLocation() { + return location; + } + + public Builder setBillingAccount(String billingAccount) { + this.billingAccount = billingAccount; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(BillingAccountLocationName billingAccountLocationName) { + billingAccount = billingAccountLocationName.billingAccount; + location = billingAccountLocationName.location; + } + + public BillingAccountLocationName build() { + return new BillingAccountLocationName(this); + } + } +} diff --git a/test/integration/goldens/logging/BillingAccountName.java b/test/integration/goldens/logging/BillingAccountName.java new file mode 100644 index 0000000000..aac4c70071 --- /dev/null +++ b/test/integration/goldens/logging/BillingAccountName.java @@ -0,0 +1,163 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class BillingAccountName implements ResourceName { + private static final PathTemplate BILLING_ACCOUNT = + PathTemplate.createWithoutUrlEncoding("billingAccounts/{billing_account}"); + private volatile Map fieldValuesMap; + private final String billingAccount; + + private BillingAccountName(Builder builder) { + billingAccount = Preconditions.checkNotNull(builder.getBillingAccount()); + } + + public String getBillingAccount() { + return billingAccount; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static BillingAccountName of(String billingAccount) { + return newBuilder().setBillingAccount(billingAccount).build(); + } + + public static String format(String billingAccount) { + return newBuilder().setBillingAccount(billingAccount).build().toString(); + } + + public static BillingAccountName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + BILLING_ACCOUNT.validatedMatch( + formattedString, "BillingAccountName.parse: formattedString not in valid format"); + return of(matchMap.get("billing_account")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (BillingAccountName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return BILLING_ACCOUNT.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(billingAccount)) { + fieldMapBuilder.put("billing_account", billingAccount); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return BILLING_ACCOUNT.instantiate("billing_account", billingAccount); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + BillingAccountName that = ((BillingAccountName) o); + return Objects.equals(this.billingAccount, that.billingAccount); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(billingAccount); + return h; + } + + /** Builder for billingAccounts/{billing_account}. */ + public static class Builder { + private String billingAccount; + + private Builder() {} + + public String getBillingAccount() { + return billingAccount; + } + + public Builder setBillingAccount(String billingAccount) { + this.billingAccount = billingAccount; + return this; + } + + private Builder(BillingAccountName billingAccountName) { + billingAccount = billingAccountName.billingAccount; + } + + public BillingAccountName build() { + return new BillingAccountName(this); + } + } +} diff --git a/test/integration/goldens/logging/CmekSettingsName.java b/test/integration/goldens/logging/CmekSettingsName.java new file mode 100644 index 0000000000..e90b6428a1 --- /dev/null +++ b/test/integration/goldens/logging/CmekSettingsName.java @@ -0,0 +1,375 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class CmekSettingsName implements ResourceName { + private static final PathTemplate PROJECT = + PathTemplate.createWithoutUrlEncoding("projects/{project}/cmekSettings"); + private static final PathTemplate ORGANIZATION = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}/cmekSettings"); + private static final PathTemplate FOLDER = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/cmekSettings"); + private static final PathTemplate BILLING_ACCOUNT = + PathTemplate.createWithoutUrlEncoding("billingAccounts/{billing_account}/cmekSettings"); + private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; + private final String project; + private final String organization; + private final String folder; + private final String billingAccount; + + private CmekSettingsName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + organization = null; + folder = null; + billingAccount = null; + pathTemplate = PROJECT; + } + + private CmekSettingsName(OrganizationBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + project = null; + folder = null; + billingAccount = null; + pathTemplate = ORGANIZATION; + } + + private CmekSettingsName(FolderBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + project = null; + organization = null; + billingAccount = null; + pathTemplate = FOLDER; + } + + private CmekSettingsName(BillingAccountBuilder builder) { + billingAccount = Preconditions.checkNotNull(builder.getBillingAccount()); + project = null; + organization = null; + folder = null; + pathTemplate = BILLING_ACCOUNT; + } + + public String getProject() { + return project; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; + } + + public String getBillingAccount() { + return billingAccount; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationBuilder newOrganizationBuilder() { + return new OrganizationBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderBuilder newFolderBuilder() { + return new FolderBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static BillingAccountBuilder newBillingAccountBuilder() { + return new BillingAccountBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static CmekSettingsName of(String project) { + return newBuilder().setProject(project).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static CmekSettingsName ofProjectName(String project) { + return newBuilder().setProject(project).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static CmekSettingsName ofOrganizationName(String organization) { + return newOrganizationBuilder().setOrganization(organization).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static CmekSettingsName ofFolderName(String folder) { + return newFolderBuilder().setFolder(folder).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static CmekSettingsName ofBillingAccountName(String billingAccount) { + return newBillingAccountBuilder().setBillingAccount(billingAccount).build(); + } + + public static String format(String project) { + return newBuilder().setProject(project).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectName(String project) { + return newBuilder().setProject(project).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationName(String organization) { + return newOrganizationBuilder().setOrganization(organization).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderName(String folder) { + return newFolderBuilder().setFolder(folder).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatBillingAccountName(String billingAccount) { + return newBillingAccountBuilder().setBillingAccount(billingAccount).build().toString(); + } + + public static CmekSettingsName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + if (PROJECT.matches(formattedString)) { + Map matchMap = PROJECT.match(formattedString); + return ofProjectName(matchMap.get("project")); + } else if (ORGANIZATION.matches(formattedString)) { + Map matchMap = ORGANIZATION.match(formattedString); + return ofOrganizationName(matchMap.get("organization")); + } else if (FOLDER.matches(formattedString)) { + Map matchMap = FOLDER.match(formattedString); + return ofFolderName(matchMap.get("folder")); + } else if (BILLING_ACCOUNT.matches(formattedString)) { + Map matchMap = BILLING_ACCOUNT.match(formattedString); + return ofBillingAccountName(matchMap.get("billing_account")); + } + throw new ValidationException("CmekSettingsName.parse: formattedString not in valid format"); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (CmekSettingsName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT.matches(formattedString) + || ORGANIZATION.matches(formattedString) + || FOLDER.matches(formattedString) + || BILLING_ACCOUNT.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } + if (!Objects.isNull(organization)) { + fieldMapBuilder.put("organization", organization); + } + if (!Objects.isNull(folder)) { + fieldMapBuilder.put("folder", folder); + } + if (!Objects.isNull(billingAccount)) { + fieldMapBuilder.put("billing_account", billingAccount); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + CmekSettingsName that = ((CmekSettingsName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder) + && Objects.equals(this.billingAccount, that.billingAccount); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(billingAccount); + return h; + } + + /** Builder for projects/{project}/cmekSettings. */ + public static class Builder { + private String project; + + private Builder() {} + + public String getProject() { + return project; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + private Builder(CmekSettingsName cmekSettingsName) { + Preconditions.checkArgument( + Objects.equals(cmekSettingsName.pathTemplate, PROJECT), + "toBuilder is only supported when CmekSettingsName has the pattern of projects/{project}/cmekSettings"); + project = cmekSettingsName.project; + } + + public CmekSettingsName build() { + return new CmekSettingsName(this); + } + } + + /** Builder for organizations/{organization}/cmekSettings. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationBuilder { + private String organization; + + private OrganizationBuilder() {} + + public String getOrganization() { + return organization; + } + + public OrganizationBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public CmekSettingsName build() { + return new CmekSettingsName(this); + } + } + + /** Builder for folders/{folder}/cmekSettings. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderBuilder { + private String folder; + + private FolderBuilder() {} + + public String getFolder() { + return folder; + } + + public FolderBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public CmekSettingsName build() { + return new CmekSettingsName(this); + } + } + + /** Builder for billingAccounts/{billing_account}/cmekSettings. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class BillingAccountBuilder { + private String billingAccount; + + private BillingAccountBuilder() {} + + public String getBillingAccount() { + return billingAccount; + } + + public BillingAccountBuilder setBillingAccount(String billingAccount) { + this.billingAccount = billingAccount; + return this; + } + + public CmekSettingsName build() { + return new CmekSettingsName(this); + } + } +} diff --git a/test/integration/goldens/logging/ConfigServiceV2Client.java b/test/integration/goldens/logging/ConfigServiceV2Client.java new file mode 100644 index 0000000000..f3b1c319ba --- /dev/null +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -0,0 +1,1707 @@ +/* + * Copyright 2020 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.logging.v2; + +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.common.util.concurrent.MoreExecutors; +import com.google.logging.v2.stub.ConfigServiceV2Stub; +import com.google.logging.v2.stub.ConfigServiceV2StubSettings; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: Service for configuring sinks used to route log entries. + * + *

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: + * + *

Note: close() needs to be called on the echoClient 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 ConfigServiceV2Settings to + * create(). For example: + * + *

To customize credentials: + * + *

To customize the endpoint: + */ +@BetaApi +@Generated("by gapic-generator") +public class ConfigServiceV2Client implements BackgroundResource { + private final ConfigServiceV2Settings settings; + private final ConfigServiceV2Stub stub; + + /** Constructs an instance of EchoClient with default settings. */ + public static final ConfigServiceV2Client create() throws IOException { + return create(ConfigServiceV2Settings.newBuilder().build()); + } + + /** + * Constructs an instance of EchoClient, 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 ConfigServiceV2Client create(ConfigServiceV2Settings settings) + throws IOException { + return new ConfigServiceV2Client(settings); + } + + /** + * Constructs an instance of EchoClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(ConfigServiceV2Settings). + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final ConfigServiceV2Client create(ConfigServiceV2Stub stub) { + return new ConfigServiceV2Client(stub); + } + + /** + * Constructs an instance of EchoClient, 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 ConfigServiceV2Client(ConfigServiceV2Settings settings) throws IOException { + this.settings = settings; + this.stub = ((ConfigServiceV2StubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected ConfigServiceV2Client(ConfigServiceV2Stub stub) { + this.settings = null; + this.stub = stub; + } + + public final ConfigServiceV2Settings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public ConfigServiceV2Stub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists buckets (Beta). + * + *

Sample code: + * + * @param parent Required. The parent resource whose buckets are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" Note: The locations portion of the resource + * must be specified, but supplying the character `-` in place of [LOCATION_ID] will return + * all buckets. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBucketsPagedResponse listBuckets(BillingAccountLocationName parent) { + ListBucketsRequest request = + ListBucketsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listBuckets(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists buckets (Beta). + * + *

Sample code: + * + * @param parent Required. The parent resource whose buckets are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" Note: The locations portion of the resource + * must be specified, but supplying the character `-` in place of [LOCATION_ID] will return + * all buckets. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBucketsPagedResponse listBuckets(FolderLocationName parent) { + ListBucketsRequest request = + ListBucketsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listBuckets(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists buckets (Beta). + * + *

Sample code: + * + * @param parent Required. The parent resource whose buckets are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" Note: The locations portion of the resource + * must be specified, but supplying the character `-` in place of [LOCATION_ID] will return + * all buckets. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBucketsPagedResponse listBuckets(LocationName parent) { + ListBucketsRequest request = + ListBucketsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listBuckets(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists buckets (Beta). + * + *

Sample code: + * + * @param parent Required. The parent resource whose buckets are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" Note: The locations portion of the resource + * must be specified, but supplying the character `-` in place of [LOCATION_ID] will return + * all buckets. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBucketsPagedResponse listBuckets(OrganizationLocationName parent) { + ListBucketsRequest request = + ListBucketsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listBuckets(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists buckets (Beta). + * + *

Sample code: + * + * @param parent Required. The parent resource whose buckets are to be listed: + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" Note: The locations portion of the resource + * must be specified, but supplying the character `-` in place of [LOCATION_ID] will return + * all buckets. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBucketsPagedResponse listBuckets(String parent) { + ListBucketsRequest request = ListBucketsRequest.newBuilder().setParent(parent).build(); + return listBuckets(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists buckets (Beta). + * + *

Sample code: + * + * @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 + */ + public final ListBucketsPagedResponse listBuckets(ListBucketsRequest request) { + return listBucketsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists buckets (Beta). + * + *

Sample code: + */ + public final UnaryCallable + listBucketsPagedCallable() { + return stub.listBucketsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists buckets (Beta). + * + *

Sample code: + */ + public final UnaryCallable listBucketsCallable() { + return stub.listBucketsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a bucket (Beta). + * + *

Sample code: + * + * @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 + */ + public final LogBucket getBucket(GetBucketRequest request) { + return getBucketCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a bucket (Beta). + * + *

Sample code: + */ + public final UnaryCallable getBucketCallable() { + return stub.getBucketCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a bucket. This method replaces the following fields in the existing bucket with values + * from the new bucket: `retention_period` If the retention period is decreased and the bucket is + * locked, FAILED_PRECONDITION will be returned. If the bucket has a LifecycleState of + * DELETE_REQUESTED, FAILED_PRECONDITION will be returned. A buckets region may not be modified + * after it is created. This method is in Beta. + * + *

Sample code: + * + * @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 + */ + public final LogBucket updateBucket(UpdateBucketRequest request) { + return updateBucketCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a bucket. This method replaces the following fields in the existing bucket with values + * from the new bucket: `retention_period` If the retention period is decreased and the bucket is + * locked, FAILED_PRECONDITION will be returned. If the bucket has a LifecycleState of + * DELETE_REQUESTED, FAILED_PRECONDITION will be returned. A buckets region may not be modified + * after it is created. This method is in Beta. + * + *

Sample code: + */ + public final UnaryCallable updateBucketCallable() { + return stub.updateBucketCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists sinks. + * + *

Sample code: + * + * @param parent Required. The parent resource whose sinks are to be listed: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSinksPagedResponse listSinks(BillingAccountName parent) { + ListSinksRequest request = + ListSinksRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listSinks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists sinks. + * + *

Sample code: + * + * @param parent Required. The parent resource whose sinks are to be listed: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSinksPagedResponse listSinks(FolderName parent) { + ListSinksRequest request = + ListSinksRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listSinks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists sinks. + * + *

Sample code: + * + * @param parent Required. The parent resource whose sinks are to be listed: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSinksPagedResponse listSinks(OrganizationName parent) { + ListSinksRequest request = + ListSinksRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listSinks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists sinks. + * + *

Sample code: + * + * @param parent Required. The parent resource whose sinks are to be listed: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSinksPagedResponse listSinks(ProjectName parent) { + ListSinksRequest request = + ListSinksRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listSinks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists sinks. + * + *

Sample code: + * + * @param parent Required. The parent resource whose sinks are to be listed: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSinksPagedResponse listSinks(String parent) { + ListSinksRequest request = ListSinksRequest.newBuilder().setParent(parent).build(); + return listSinks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists sinks. + * + *

Sample code: + * + * @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 + */ + public final ListSinksPagedResponse listSinks(ListSinksRequest request) { + return listSinksPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists sinks. + * + *

Sample code: + */ + public final UnaryCallable listSinksPagedCallable() { + return stub.listSinksPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists sinks. + * + *

Sample code: + */ + public final UnaryCallable listSinksCallable() { + return stub.listSinksCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a sink. + * + *

Sample code: + * + * @param sink_name Required. The resource name of the sink: + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink getSink(LogSinkName sinkName) { + GetSinkRequest request = + GetSinkRequest.newBuilder() + .setSinkName(Objects.isNull(sinkName) ? null : sinkName.toString()) + .build(); + return getSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a sink. + * + *

Sample code: + * + * @param sink_name Required. The resource name of the sink: + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink getSink(String sinkName) { + GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(sinkName).build(); + return getSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a sink. + * + *

Sample code: + * + * @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 + */ + public final LogSink getSink(GetSinkRequest request) { + return getSinkCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a sink. + * + *

Sample code: + */ + public final UnaryCallable getSinkCallable() { + return stub.getSinkCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a sink that exports specified log entries to a destination. The export of + * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not + * permitted to write to the destination. A sink can export log entries only from the resource + * owning the sink. + * + *

Sample code: + * + * @param parent Required. The resource in which to create the sink: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" Examples: `"projects/my-logging-project"`, + * `"organizations/123456789"`. + * @param sink Required. The new sink, whose `name` parameter is a sink identifier that is not + * already in use. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink createSink(BillingAccountName parent, LogSink sink) { + CreateSinkRequest request = + CreateSinkRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setSink(sink) + .build(); + return createSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a sink that exports specified log entries to a destination. The export of + * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not + * permitted to write to the destination. A sink can export log entries only from the resource + * owning the sink. + * + *

Sample code: + * + * @param parent Required. The resource in which to create the sink: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" Examples: `"projects/my-logging-project"`, + * `"organizations/123456789"`. + * @param sink Required. The new sink, whose `name` parameter is a sink identifier that is not + * already in use. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink createSink(FolderName parent, LogSink sink) { + CreateSinkRequest request = + CreateSinkRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setSink(sink) + .build(); + return createSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a sink that exports specified log entries to a destination. The export of + * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not + * permitted to write to the destination. A sink can export log entries only from the resource + * owning the sink. + * + *

Sample code: + * + * @param parent Required. The resource in which to create the sink: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" Examples: `"projects/my-logging-project"`, + * `"organizations/123456789"`. + * @param sink Required. The new sink, whose `name` parameter is a sink identifier that is not + * already in use. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink createSink(OrganizationName parent, LogSink sink) { + CreateSinkRequest request = + CreateSinkRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setSink(sink) + .build(); + return createSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a sink that exports specified log entries to a destination. The export of + * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not + * permitted to write to the destination. A sink can export log entries only from the resource + * owning the sink. + * + *

Sample code: + * + * @param parent Required. The resource in which to create the sink: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" Examples: `"projects/my-logging-project"`, + * `"organizations/123456789"`. + * @param sink Required. The new sink, whose `name` parameter is a sink identifier that is not + * already in use. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink createSink(ProjectName parent, LogSink sink) { + CreateSinkRequest request = + CreateSinkRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setSink(sink) + .build(); + return createSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a sink that exports specified log entries to a destination. The export of + * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not + * permitted to write to the destination. A sink can export log entries only from the resource + * owning the sink. + * + *

Sample code: + * + * @param parent Required. The resource in which to create the sink: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" Examples: `"projects/my-logging-project"`, + * `"organizations/123456789"`. + * @param sink Required. The new sink, whose `name` parameter is a sink identifier that is not + * already in use. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink createSink(String parent, LogSink sink) { + CreateSinkRequest request = + CreateSinkRequest.newBuilder().setParent(parent).setSink(sink).build(); + return createSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a sink that exports specified log entries to a destination. The export of + * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not + * permitted to write to the destination. A sink can export log entries only from the resource + * owning the sink. + * + *

Sample code: + * + * @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 + */ + public final LogSink createSink(CreateSinkRequest request) { + return createSinkCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a sink that exports specified log entries to a destination. The export of + * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not + * permitted to write to the destination. A sink can export log entries only from the resource + * owning the sink. + * + *

Sample code: + */ + public final UnaryCallable createSinkCallable() { + return stub.createSinkCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a sink. This method replaces the following fields in the existing sink with values from + * the new sink: `destination`, and `filter`. The updated sink might also have a new + * `writer_identity`; see the `unique_writer_identity` field. + * + *

Sample code: + * + * @param sink_name Required. The full resource name of the sink to update, including the parent + * resource and the sink identifier: "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param sink Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink updateSink(LogSinkName sinkName, LogSink sink) { + UpdateSinkRequest request = + UpdateSinkRequest.newBuilder() + .setSinkName(Objects.isNull(sinkName) ? null : sinkName.toString()) + .setSink(sink) + .build(); + return updateSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a sink. This method replaces the following fields in the existing sink with values from + * the new sink: `destination`, and `filter`. The updated sink might also have a new + * `writer_identity`; see the `unique_writer_identity` field. + * + *

Sample code: + * + * @param sink_name Required. The full resource name of the sink to update, including the parent + * resource and the sink identifier: "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param sink Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink updateSink(String sinkName, LogSink sink) { + UpdateSinkRequest request = + UpdateSinkRequest.newBuilder().setSinkName(sinkName).setSink(sink).build(); + return updateSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a sink. This method replaces the following fields in the existing sink with values from + * the new sink: `destination`, and `filter`. The updated sink might also have a new + * `writer_identity`; see the `unique_writer_identity` field. + * + *

Sample code: + * + * @param sink_name Required. The full resource name of the sink to update, including the parent + * resource and the sink identifier: "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param sink Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. + * @param update_mask Optional. Field mask that specifies the fields in `sink` that need an + * update. A sink field will be overwritten if, and only if, it is in the update mask. `name` + * and output only fields cannot be updated. An empty updateMask is temporarily treated as + * using the following mask for backwards compatibility purposes: + * destination,filter,includeChildren At some point in the future, behavior will be removed + * and specifying an empty updateMask will be an error. For a detailed `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * Example: `updateMask=filter`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink updateSink(LogSinkName sinkName, LogSink sink, FieldMask updateMask) { + UpdateSinkRequest request = + UpdateSinkRequest.newBuilder() + .setSinkName(Objects.isNull(sinkName) ? null : sinkName.toString()) + .setSink(sink) + .setUpdateMask(updateMask) + .build(); + return updateSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a sink. This method replaces the following fields in the existing sink with values from + * the new sink: `destination`, and `filter`. The updated sink might also have a new + * `writer_identity`; see the `unique_writer_identity` field. + * + *

Sample code: + * + * @param sink_name Required. The full resource name of the sink to update, including the parent + * resource and the sink identifier: "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param sink Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. + * @param update_mask Optional. Field mask that specifies the fields in `sink` that need an + * update. A sink field will be overwritten if, and only if, it is in the update mask. `name` + * and output only fields cannot be updated. An empty updateMask is temporarily treated as + * using the following mask for backwards compatibility purposes: + * destination,filter,includeChildren At some point in the future, behavior will be removed + * and specifying an empty updateMask will be an error. For a detailed `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * Example: `updateMask=filter`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogSink updateSink(String sinkName, LogSink sink, FieldMask updateMask) { + UpdateSinkRequest request = + UpdateSinkRequest.newBuilder() + .setSinkName(sinkName) + .setSink(sink) + .setUpdateMask(updateMask) + .build(); + return updateSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a sink. This method replaces the following fields in the existing sink with values from + * the new sink: `destination`, and `filter`. The updated sink might also have a new + * `writer_identity`; see the `unique_writer_identity` field. + * + *

Sample code: + * + * @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 + */ + public final LogSink updateSink(UpdateSinkRequest request) { + return updateSinkCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a sink. This method replaces the following fields in the existing sink with values from + * the new sink: `destination`, and `filter`. The updated sink might also have a new + * `writer_identity`; see the `unique_writer_identity` field. + * + *

Sample code: + */ + public final UnaryCallable updateSinkCallable() { + return stub.updateSinkCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a sink. If the sink has a unique `writer_identity`, then that service account is also + * deleted. + * + *

Sample code: + * + * @param sink_name Required. The full resource name of the sink to delete, including the parent + * resource and the sink identifier: "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Empty deleteSink(LogSinkName sinkName) { + DeleteSinkRequest request = + DeleteSinkRequest.newBuilder() + .setSinkName(Objects.isNull(sinkName) ? null : sinkName.toString()) + .build(); + return deleteSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a sink. If the sink has a unique `writer_identity`, then that service account is also + * deleted. + * + *

Sample code: + * + * @param sink_name Required. The full resource name of the sink to delete, including the parent + * resource and the sink identifier: "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Empty deleteSink(String sinkName) { + DeleteSinkRequest request = DeleteSinkRequest.newBuilder().setSinkName(sinkName).build(); + return deleteSink(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a sink. If the sink has a unique `writer_identity`, then that service account is also + * deleted. + * + *

Sample code: + * + * @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 + */ + public final Empty deleteSink(DeleteSinkRequest request) { + return deleteSinkCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a sink. If the sink has a unique `writer_identity`, then that service account is also + * deleted. + * + *

Sample code: + */ + public final UnaryCallable deleteSinkCallable() { + return stub.deleteSinkCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the exclusions in a parent resource. + * + *

Sample code: + * + * @param parent Required. The parent resource whose exclusions are to be listed. + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListExclusionsPagedResponse listExclusions(BillingAccountName parent) { + ListExclusionsRequest request = + ListExclusionsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listExclusions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the exclusions in a parent resource. + * + *

Sample code: + * + * @param parent Required. The parent resource whose exclusions are to be listed. + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListExclusionsPagedResponse listExclusions(FolderName parent) { + ListExclusionsRequest request = + ListExclusionsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listExclusions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the exclusions in a parent resource. + * + *

Sample code: + * + * @param parent Required. The parent resource whose exclusions are to be listed. + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListExclusionsPagedResponse listExclusions(OrganizationName parent) { + ListExclusionsRequest request = + ListExclusionsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listExclusions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the exclusions in a parent resource. + * + *

Sample code: + * + * @param parent Required. The parent resource whose exclusions are to be listed. + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListExclusionsPagedResponse listExclusions(ProjectName parent) { + ListExclusionsRequest request = + ListExclusionsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listExclusions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the exclusions in a parent resource. + * + *

Sample code: + * + * @param parent Required. The parent resource whose exclusions are to be listed. + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListExclusionsPagedResponse listExclusions(String parent) { + ListExclusionsRequest request = ListExclusionsRequest.newBuilder().setParent(parent).build(); + return listExclusions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the exclusions in a parent resource. + * + *

Sample code: + * + * @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 + */ + public final ListExclusionsPagedResponse listExclusions(ListExclusionsRequest request) { + return listExclusionsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the exclusions in a parent resource. + * + *

Sample code: + */ + public final UnaryCallable + listExclusionsPagedCallable() { + return stub.listExclusionsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the exclusions in a parent resource. + * + *

Sample code: + */ + public final UnaryCallable + listExclusionsCallable() { + return stub.listExclusionsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the description of an exclusion. + * + *

Sample code: + * + * @param name Required. The resource name of an existing exclusion: + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" Example: + * `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion getExclusion(LogExclusionName name) { + GetExclusionRequest request = + GetExclusionRequest.newBuilder() + .setName(Objects.isNull(name) ? null : name.toString()) + .build(); + return getExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the description of an exclusion. + * + *

Sample code: + * + * @param name Required. The resource name of an existing exclusion: + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" Example: + * `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion getExclusion(String name) { + GetExclusionRequest request = GetExclusionRequest.newBuilder().setName(name).build(); + return getExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the description of an exclusion. + * + *

Sample code: + * + * @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 + */ + public final LogExclusion getExclusion(GetExclusionRequest request) { + return getExclusionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the description of an exclusion. + * + *

Sample code: + */ + public final UnaryCallable getExclusionCallable() { + return stub.getExclusionCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new exclusion in a specified parent resource. Only log entries belonging to that + * resource can be excluded. You can have up to 10 exclusions in a resource. + * + *

Sample code: + * + * @param parent Required. The parent resource in which to create the exclusion: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" Examples: + * `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param exclusion Required. The new exclusion, whose `name` parameter is an exclusion name that + * is not already used in the parent resource. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion createExclusion(BillingAccountName parent, LogExclusion exclusion) { + CreateExclusionRequest request = + CreateExclusionRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setExclusion(exclusion) + .build(); + return createExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new exclusion in a specified parent resource. Only log entries belonging to that + * resource can be excluded. You can have up to 10 exclusions in a resource. + * + *

Sample code: + * + * @param parent Required. The parent resource in which to create the exclusion: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" Examples: + * `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param exclusion Required. The new exclusion, whose `name` parameter is an exclusion name that + * is not already used in the parent resource. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion createExclusion(FolderName parent, LogExclusion exclusion) { + CreateExclusionRequest request = + CreateExclusionRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setExclusion(exclusion) + .build(); + return createExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new exclusion in a specified parent resource. Only log entries belonging to that + * resource can be excluded. You can have up to 10 exclusions in a resource. + * + *

Sample code: + * + * @param parent Required. The parent resource in which to create the exclusion: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" Examples: + * `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param exclusion Required. The new exclusion, whose `name` parameter is an exclusion name that + * is not already used in the parent resource. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion createExclusion(OrganizationName parent, LogExclusion exclusion) { + CreateExclusionRequest request = + CreateExclusionRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setExclusion(exclusion) + .build(); + return createExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new exclusion in a specified parent resource. Only log entries belonging to that + * resource can be excluded. You can have up to 10 exclusions in a resource. + * + *

Sample code: + * + * @param parent Required. The parent resource in which to create the exclusion: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" Examples: + * `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param exclusion Required. The new exclusion, whose `name` parameter is an exclusion name that + * is not already used in the parent resource. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion createExclusion(ProjectName parent, LogExclusion exclusion) { + CreateExclusionRequest request = + CreateExclusionRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setExclusion(exclusion) + .build(); + return createExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new exclusion in a specified parent resource. Only log entries belonging to that + * resource can be excluded. You can have up to 10 exclusions in a resource. + * + *

Sample code: + * + * @param parent Required. The parent resource in which to create the exclusion: + * "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" Examples: + * `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param exclusion Required. The new exclusion, whose `name` parameter is an exclusion name that + * is not already used in the parent resource. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion createExclusion(String parent, LogExclusion exclusion) { + CreateExclusionRequest request = + CreateExclusionRequest.newBuilder().setParent(parent).setExclusion(exclusion).build(); + return createExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new exclusion in a specified parent resource. Only log entries belonging to that + * resource can be excluded. You can have up to 10 exclusions in a resource. + * + *

Sample code: + * + * @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 + */ + public final LogExclusion createExclusion(CreateExclusionRequest request) { + return createExclusionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new exclusion in a specified parent resource. Only log entries belonging to that + * resource can be excluded. You can have up to 10 exclusions in a resource. + * + *

Sample code: + */ + public final UnaryCallable createExclusionCallable() { + return stub.createExclusionCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Changes one or more properties of an existing exclusion. + * + *

Sample code: + * + * @param name Required. The resource name of the exclusion to update: + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" Example: + * `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param exclusion Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. + * @param update_mask Required. A non-empty list of fields to change in the existing exclusion. + * New values for the fields are taken from the corresponding fields in the + * [LogExclusion][google.logging.v2.LogExclusion] included in this request. Fields not + * mentioned in `update_mask` are not changed and are ignored in the request. For example, to + * change the filter and description of an exclusion, specify an `update_mask` of + * `"filter,description"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion updateExclusion( + LogExclusionName name, LogExclusion exclusion, FieldMask updateMask) { + UpdateExclusionRequest request = + UpdateExclusionRequest.newBuilder() + .setName(Objects.isNull(name) ? null : name.toString()) + .setExclusion(exclusion) + .setUpdateMask(updateMask) + .build(); + return updateExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Changes one or more properties of an existing exclusion. + * + *

Sample code: + * + * @param name Required. The resource name of the exclusion to update: + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" Example: + * `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param exclusion Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. + * @param update_mask Required. A non-empty list of fields to change in the existing exclusion. + * New values for the fields are taken from the corresponding fields in the + * [LogExclusion][google.logging.v2.LogExclusion] included in this request. Fields not + * mentioned in `update_mask` are not changed and are ignored in the request. For example, to + * change the filter and description of an exclusion, specify an `update_mask` of + * `"filter,description"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogExclusion updateExclusion( + String name, LogExclusion exclusion, FieldMask updateMask) { + UpdateExclusionRequest request = + UpdateExclusionRequest.newBuilder() + .setName(name) + .setExclusion(exclusion) + .setUpdateMask(updateMask) + .build(); + return updateExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Changes one or more properties of an existing exclusion. + * + *

Sample code: + * + * @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 + */ + public final LogExclusion updateExclusion(UpdateExclusionRequest request) { + return updateExclusionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Changes one or more properties of an existing exclusion. + * + *

Sample code: + */ + public final UnaryCallable updateExclusionCallable() { + return stub.updateExclusionCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an exclusion. + * + *

Sample code: + * + * @param name Required. The resource name of an existing exclusion to delete: + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" Example: + * `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Empty deleteExclusion(LogExclusionName name) { + DeleteExclusionRequest request = + DeleteExclusionRequest.newBuilder() + .setName(Objects.isNull(name) ? null : name.toString()) + .build(); + return deleteExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an exclusion. + * + *

Sample code: + * + * @param name Required. The resource name of an existing exclusion to delete: + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" Example: + * `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Empty deleteExclusion(String name) { + DeleteExclusionRequest request = DeleteExclusionRequest.newBuilder().setName(name).build(); + return deleteExclusion(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an exclusion. + * + *

Sample code: + * + * @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 + */ + public final Empty deleteExclusion(DeleteExclusionRequest request) { + return deleteExclusionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an exclusion. + * + *

Sample code: + */ + public final UnaryCallable deleteExclusionCallable() { + return stub.deleteExclusionCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the Logs Router CMEK settings for the given resource. Note: CMEK for the Logs Router can + * currently only be configured for GCP organizations. Once configured, it applies to all projects + * and folders in the GCP organization. See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for more information. + * + *

Sample code: + * + * @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 + */ + public final CmekSettings getCmekSettings(GetCmekSettingsRequest request) { + return getCmekSettingsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the Logs Router CMEK settings for the given resource. Note: CMEK for the Logs Router can + * currently only be configured for GCP organizations. Once configured, it applies to all projects + * and folders in the GCP organization. See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for more information. + * + *

Sample code: + */ + public final UnaryCallable getCmekSettingsCallable() { + return stub.getCmekSettingsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the Logs Router CMEK settings for the given resource. Note: CMEK for the Logs Router + * can currently only be configured for GCP organizations. Once configured, it applies to all + * projects and folders in the GCP organization. + * [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings] will fail if 1) + * `kms_key_name` is invalid, or 2) the associated service account does not have the required + * `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or 3) access to the key + * is disabled. See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for more information. + * + *

Sample code: + * + * @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 + */ + public final CmekSettings updateCmekSettings(UpdateCmekSettingsRequest request) { + return updateCmekSettingsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the Logs Router CMEK settings for the given resource. Note: CMEK for the Logs Router + * can currently only be configured for GCP organizations. Once configured, it applies to all + * projects and folders in the GCP organization. + * [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings] will fail if 1) + * `kms_key_name` is invalid, or 2) the associated service account does not have the required + * `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or 3) access to the key + * is disabled. See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) for more information. + * + *

Sample code: + */ + public final UnaryCallable updateCmekSettingsCallable() { + return stub.updateCmekSettingsCallable(); + } + + @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 ListBucketsPagedResponse + extends AbstractPagedListResponse< + ListBucketsRequest, + ListBucketsResponse, + LogBucket, + ListBucketsPage, + ListBucketsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListBucketsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListBucketsPagedResponse apply(ListBucketsPage input) { + return new ListBucketsPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListBucketsPagedResponse(ListBucketsPage page) { + super(page, ListBucketsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListBucketsPage + extends AbstractPage { + + private ListBucketsPage( + PageContext context, + ListBucketsResponse response) { + super(context, response); + } + + private static ListBucketsPage createEmptyPage() { + return new ListBucketsPage(null, null); + } + + @Override + protected ListBucketsPage createPage( + PageContext context, + ListBucketsResponse response) { + return new ListBucketsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListBucketsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListBucketsRequest, + ListBucketsResponse, + LogBucket, + ListBucketsPage, + ListBucketsFixedSizeCollection> { + + private ListBucketsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListBucketsFixedSizeCollection createEmptyCollection() { + return new ListBucketsFixedSizeCollection(null, 0); + } + + @Override + protected ListBucketsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListBucketsFixedSizeCollection(pages, collectionSize); + } + } + + public static class ListSinksPagedResponse + extends AbstractPagedListResponse< + ListSinksRequest, + ListSinksResponse, + LogSink, + ListSinksPage, + ListSinksFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListSinksPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListSinksPagedResponse apply(ListSinksPage input) { + return new ListSinksPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListSinksPagedResponse(ListSinksPage page) { + super(page, ListSinksFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListSinksPage + extends AbstractPage { + + private ListSinksPage( + PageContext context, + ListSinksResponse response) { + super(context, response); + } + + private static ListSinksPage createEmptyPage() { + return new ListSinksPage(null, null); + } + + @Override + protected ListSinksPage createPage( + PageContext context, + ListSinksResponse response) { + return new ListSinksPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListSinksFixedSizeCollection + extends AbstractFixedSizeCollection< + ListSinksRequest, + ListSinksResponse, + LogSink, + ListSinksPage, + ListSinksFixedSizeCollection> { + + private ListSinksFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListSinksFixedSizeCollection createEmptyCollection() { + return new ListSinksFixedSizeCollection(null, 0); + } + + @Override + protected ListSinksFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListSinksFixedSizeCollection(pages, collectionSize); + } + } + + public static class ListExclusionsPagedResponse + extends AbstractPagedListResponse< + ListExclusionsRequest, + ListExclusionsResponse, + LogExclusion, + ListExclusionsPage, + ListExclusionsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListExclusionsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListExclusionsPagedResponse apply(ListExclusionsPage input) { + return new ListExclusionsPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListExclusionsPagedResponse(ListExclusionsPage page) { + super(page, ListExclusionsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListExclusionsPage + extends AbstractPage< + ListExclusionsRequest, ListExclusionsResponse, LogExclusion, ListExclusionsPage> { + + private ListExclusionsPage( + PageContext context, + ListExclusionsResponse response) { + super(context, response); + } + + private static ListExclusionsPage createEmptyPage() { + return new ListExclusionsPage(null, null); + } + + @Override + protected ListExclusionsPage createPage( + PageContext context, + ListExclusionsResponse response) { + return new ListExclusionsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListExclusionsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListExclusionsRequest, + ListExclusionsResponse, + LogExclusion, + ListExclusionsPage, + ListExclusionsFixedSizeCollection> { + + private ListExclusionsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListExclusionsFixedSizeCollection createEmptyCollection() { + return new ListExclusionsFixedSizeCollection(null, 0); + } + + @Override + protected ListExclusionsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListExclusionsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/test/integration/goldens/logging/ConfigServiceV2Settings.java b/test/integration/goldens/logging/ConfigServiceV2Settings.java new file mode 100644 index 0000000000..1ae26f5c78 --- /dev/null +++ b/test/integration/goldens/logging/ConfigServiceV2Settings.java @@ -0,0 +1,327 @@ +/* + * Copyright 2020 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.logging.v2; + +import static com.google.logging.v2.ConfigServiceV2Client.ListBucketsPagedResponse; +import static com.google.logging.v2.ConfigServiceV2Client.ListExclusionsPagedResponse; +import static com.google.logging.v2.ConfigServiceV2Client.ListSinksPagedResponse; + +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.grpc.InstantiatingGrpcChannelProvider; +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.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.logging.v2.stub.ConfigServiceV2StubSettings; +import com.google.protobuf.Empty; +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 ConfigServiceV2Client}. + * + *

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

    + *
  • The default service address (logging.googleapis.com) 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 listBuckets to 30 seconds: + */ +@Generated("by gapic-generator-java") +public class ConfigServiceV2Settings extends ClientSettings { + + /** Returns the object with the settings used for calls to listBuckets. */ + public PagedCallSettings + listBucketsSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).listBucketsSettings(); + } + + /** Returns the object with the settings used for calls to getBucket. */ + public UnaryCallSettings getBucketSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).getBucketSettings(); + } + + /** Returns the object with the settings used for calls to updateBucket. */ + public UnaryCallSettings updateBucketSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).updateBucketSettings(); + } + + /** Returns the object with the settings used for calls to listSinks. */ + public PagedCallSettings + listSinksSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).listSinksSettings(); + } + + /** Returns the object with the settings used for calls to getSink. */ + public UnaryCallSettings getSinkSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).getSinkSettings(); + } + + /** Returns the object with the settings used for calls to createSink. */ + public UnaryCallSettings createSinkSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).createSinkSettings(); + } + + /** Returns the object with the settings used for calls to updateSink. */ + public UnaryCallSettings updateSinkSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).updateSinkSettings(); + } + + /** Returns the object with the settings used for calls to deleteSink. */ + public UnaryCallSettings deleteSinkSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).deleteSinkSettings(); + } + + /** Returns the object with the settings used for calls to listExclusions. */ + public PagedCallSettings< + ListExclusionsRequest, ListExclusionsResponse, ListExclusionsPagedResponse> + listExclusionsSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).listExclusionsSettings(); + } + + /** Returns the object with the settings used for calls to getExclusion. */ + public UnaryCallSettings getExclusionSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).getExclusionSettings(); + } + + /** Returns the object with the settings used for calls to createExclusion. */ + public UnaryCallSettings createExclusionSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).createExclusionSettings(); + } + + /** Returns the object with the settings used for calls to updateExclusion. */ + public UnaryCallSettings updateExclusionSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).updateExclusionSettings(); + } + + /** Returns the object with the settings used for calls to deleteExclusion. */ + public UnaryCallSettings deleteExclusionSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).deleteExclusionSettings(); + } + + /** Returns the object with the settings used for calls to getCmekSettings. */ + public UnaryCallSettings getCmekSettingsSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).getCmekSettingsSettings(); + } + + /** Returns the object with the settings used for calls to updateCmekSettings. */ + public UnaryCallSettings updateCmekSettingsSettings() { + return ((ConfigServiceV2StubSettings) getStubSettings()).updateCmekSettingsSettings(); + } + + public static final ConfigServiceV2Settings create(ConfigServiceV2StubSettings stub) + throws IOException { + return new ConfigServiceV2Settings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return ConfigServiceV2StubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return ConfigServiceV2StubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return ConfigServiceV2StubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return ConfigServiceV2StubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return ConfigServiceV2StubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return ConfigServiceV2StubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConfigServiceV2StubSettings.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 ConfigServiceV2Settings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for ConfigServiceV2Settings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(ConfigServiceV2StubSettings.newBuilder(clientContext)); + } + + protected Builder(ConfigServiceV2Settings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(ConfigServiceV2StubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(ConfigServiceV2StubSettings.newBuilder()); + } + + public ConfigServiceV2StubSettings.Builder getStubSettingsBuilder() { + return ((ConfigServiceV2StubSettings.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 listBuckets. */ + public PagedCallSettings.Builder< + ListBucketsRequest, ListBucketsResponse, ListBucketsPagedResponse> + listBucketsSettings() { + return getStubSettingsBuilder().listBucketsSettings(); + } + + /** Returns the builder for the settings used for calls to getBucket. */ + public UnaryCallSettings.Builder getBucketSettings() { + return getStubSettingsBuilder().getBucketSettings(); + } + + /** Returns the builder for the settings used for calls to updateBucket. */ + public UnaryCallSettings.Builder updateBucketSettings() { + return getStubSettingsBuilder().updateBucketSettings(); + } + + /** Returns the builder for the settings used for calls to listSinks. */ + public PagedCallSettings.Builder + listSinksSettings() { + return getStubSettingsBuilder().listSinksSettings(); + } + + /** Returns the builder for the settings used for calls to getSink. */ + public UnaryCallSettings.Builder getSinkSettings() { + return getStubSettingsBuilder().getSinkSettings(); + } + + /** Returns the builder for the settings used for calls to createSink. */ + public UnaryCallSettings.Builder createSinkSettings() { + return getStubSettingsBuilder().createSinkSettings(); + } + + /** Returns the builder for the settings used for calls to updateSink. */ + public UnaryCallSettings.Builder updateSinkSettings() { + return getStubSettingsBuilder().updateSinkSettings(); + } + + /** Returns the builder for the settings used for calls to deleteSink. */ + public UnaryCallSettings.Builder deleteSinkSettings() { + return getStubSettingsBuilder().deleteSinkSettings(); + } + + /** Returns the builder for the settings used for calls to listExclusions. */ + public PagedCallSettings.Builder< + ListExclusionsRequest, ListExclusionsResponse, ListExclusionsPagedResponse> + listExclusionsSettings() { + return getStubSettingsBuilder().listExclusionsSettings(); + } + + /** Returns the builder for the settings used for calls to getExclusion. */ + public UnaryCallSettings.Builder getExclusionSettings() { + return getStubSettingsBuilder().getExclusionSettings(); + } + + /** Returns the builder for the settings used for calls to createExclusion. */ + public UnaryCallSettings.Builder + createExclusionSettings() { + return getStubSettingsBuilder().createExclusionSettings(); + } + + /** Returns the builder for the settings used for calls to updateExclusion. */ + public UnaryCallSettings.Builder + updateExclusionSettings() { + return getStubSettingsBuilder().updateExclusionSettings(); + } + + /** Returns the builder for the settings used for calls to deleteExclusion. */ + public UnaryCallSettings.Builder deleteExclusionSettings() { + return getStubSettingsBuilder().deleteExclusionSettings(); + } + + /** Returns the builder for the settings used for calls to getCmekSettings. */ + public UnaryCallSettings.Builder + getCmekSettingsSettings() { + return getStubSettingsBuilder().getCmekSettingsSettings(); + } + + /** Returns the builder for the settings used for calls to updateCmekSettings. */ + public UnaryCallSettings.Builder + updateCmekSettingsSettings() { + return getStubSettingsBuilder().updateCmekSettingsSettings(); + } + + @Override + public ConfigServiceV2Settings build() throws IOException { + return new ConfigServiceV2Settings(this); + } + } +} diff --git a/test/integration/goldens/logging/ConfigServiceV2Stub.java b/test/integration/goldens/logging/ConfigServiceV2Stub.java new file mode 100644 index 0000000000..d49d790ea8 --- /dev/null +++ b/test/integration/goldens/logging/ConfigServiceV2Stub.java @@ -0,0 +1,134 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.ConfigServiceV2Client.ListBucketsPagedResponse; +import static com.google.logging.v2.ConfigServiceV2Client.ListExclusionsPagedResponse; +import static com.google.logging.v2.ConfigServiceV2Client.ListSinksPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.logging.v2.CmekSettings; +import com.google.logging.v2.CreateExclusionRequest; +import com.google.logging.v2.CreateSinkRequest; +import com.google.logging.v2.DeleteExclusionRequest; +import com.google.logging.v2.DeleteSinkRequest; +import com.google.logging.v2.GetBucketRequest; +import com.google.logging.v2.GetCmekSettingsRequest; +import com.google.logging.v2.GetExclusionRequest; +import com.google.logging.v2.GetSinkRequest; +import com.google.logging.v2.ListBucketsRequest; +import com.google.logging.v2.ListBucketsResponse; +import com.google.logging.v2.ListExclusionsRequest; +import com.google.logging.v2.ListExclusionsResponse; +import com.google.logging.v2.ListSinksRequest; +import com.google.logging.v2.ListSinksResponse; +import com.google.logging.v2.LogBucket; +import com.google.logging.v2.LogExclusion; +import com.google.logging.v2.LogSink; +import com.google.logging.v2.UpdateBucketRequest; +import com.google.logging.v2.UpdateCmekSettingsRequest; +import com.google.logging.v2.UpdateExclusionRequest; +import com.google.logging.v2.UpdateSinkRequest; +import com.google.protobuf.Empty; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the ConfigServiceV2 service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +public abstract class ConfigServiceV2Stub implements BackgroundResource { + + public UnaryCallable listBucketsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listBucketsPagedCallable()"); + } + + public UnaryCallable listBucketsCallable() { + throw new UnsupportedOperationException("Not implemented: listBucketsCallable()"); + } + + public UnaryCallable getBucketCallable() { + throw new UnsupportedOperationException("Not implemented: getBucketCallable()"); + } + + public UnaryCallable updateBucketCallable() { + throw new UnsupportedOperationException("Not implemented: updateBucketCallable()"); + } + + public UnaryCallable listSinksPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listSinksPagedCallable()"); + } + + public UnaryCallable listSinksCallable() { + throw new UnsupportedOperationException("Not implemented: listSinksCallable()"); + } + + public UnaryCallable getSinkCallable() { + throw new UnsupportedOperationException("Not implemented: getSinkCallable()"); + } + + public UnaryCallable createSinkCallable() { + throw new UnsupportedOperationException("Not implemented: createSinkCallable()"); + } + + public UnaryCallable updateSinkCallable() { + throw new UnsupportedOperationException("Not implemented: updateSinkCallable()"); + } + + public UnaryCallable deleteSinkCallable() { + throw new UnsupportedOperationException("Not implemented: deleteSinkCallable()"); + } + + public UnaryCallable + listExclusionsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listExclusionsPagedCallable()"); + } + + public UnaryCallable listExclusionsCallable() { + throw new UnsupportedOperationException("Not implemented: listExclusionsCallable()"); + } + + public UnaryCallable getExclusionCallable() { + throw new UnsupportedOperationException("Not implemented: getExclusionCallable()"); + } + + public UnaryCallable createExclusionCallable() { + throw new UnsupportedOperationException("Not implemented: createExclusionCallable()"); + } + + public UnaryCallable updateExclusionCallable() { + throw new UnsupportedOperationException("Not implemented: updateExclusionCallable()"); + } + + public UnaryCallable deleteExclusionCallable() { + throw new UnsupportedOperationException("Not implemented: deleteExclusionCallable()"); + } + + public UnaryCallable getCmekSettingsCallable() { + throw new UnsupportedOperationException("Not implemented: getCmekSettingsCallable()"); + } + + public UnaryCallable updateCmekSettingsCallable() { + throw new UnsupportedOperationException("Not implemented: updateCmekSettingsCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/test/integration/goldens/logging/ConfigServiceV2StubSettings.java b/test/integration/goldens/logging/ConfigServiceV2StubSettings.java new file mode 100644 index 0000000000..c51140e8fc --- /dev/null +++ b/test/integration/goldens/logging/ConfigServiceV2StubSettings.java @@ -0,0 +1,806 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.ConfigServiceV2Client.ListBucketsPagedResponse; +import static com.google.logging.v2.ConfigServiceV2Client.ListExclusionsPagedResponse; +import static com.google.logging.v2.ConfigServiceV2Client.ListSinksPagedResponse; + +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.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +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.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.logging.v2.CmekSettings; +import com.google.logging.v2.CreateExclusionRequest; +import com.google.logging.v2.CreateSinkRequest; +import com.google.logging.v2.DeleteExclusionRequest; +import com.google.logging.v2.DeleteSinkRequest; +import com.google.logging.v2.GetBucketRequest; +import com.google.logging.v2.GetCmekSettingsRequest; +import com.google.logging.v2.GetExclusionRequest; +import com.google.logging.v2.GetSinkRequest; +import com.google.logging.v2.ListBucketsRequest; +import com.google.logging.v2.ListBucketsResponse; +import com.google.logging.v2.ListExclusionsRequest; +import com.google.logging.v2.ListExclusionsResponse; +import com.google.logging.v2.ListSinksRequest; +import com.google.logging.v2.ListSinksResponse; +import com.google.logging.v2.LogBucket; +import com.google.logging.v2.LogExclusion; +import com.google.logging.v2.LogSink; +import com.google.logging.v2.UpdateBucketRequest; +import com.google.logging.v2.UpdateCmekSettingsRequest; +import com.google.logging.v2.UpdateExclusionRequest; +import com.google.logging.v2.UpdateSinkRequest; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link ConfigServiceV2Stub}. + * + *

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

    + *
  • The default service address (logging.googleapis.com) 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 listBuckets to 30 seconds: + */ +@BetaApi +@Generated("by gapic-generator-java") +public class ConfigServiceV2StubSettings 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/cloud-platform.read-only") + .add("https://www.googleapis.com/auth/logging.admin") + .add("https://www.googleapis.com/auth/logging.read") + .build(); + + private final PagedCallSettings + listBucketsSettings; + private final UnaryCallSettings getBucketSettings; + private final UnaryCallSettings updateBucketSettings; + private final PagedCallSettings + listSinksSettings; + private final UnaryCallSettings getSinkSettings; + private final UnaryCallSettings createSinkSettings; + private final UnaryCallSettings updateSinkSettings; + private final UnaryCallSettings deleteSinkSettings; + private final PagedCallSettings< + ListExclusionsRequest, ListExclusionsResponse, ListExclusionsPagedResponse> + listExclusionsSettings; + private final UnaryCallSettings getExclusionSettings; + private final UnaryCallSettings createExclusionSettings; + private final UnaryCallSettings updateExclusionSettings; + private final UnaryCallSettings deleteExclusionSettings; + private final UnaryCallSettings getCmekSettingsSettings; + private final UnaryCallSettings + updateCmekSettingsSettings; + + private static final PagedListDescriptor + LIST_BUCKETS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListBucketsRequest injectToken(ListBucketsRequest payload, String token) { + return ListBucketsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListBucketsRequest injectPageSize(ListBucketsRequest payload, int pageSize) { + return ListBucketsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListBucketsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListBucketsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListBucketsResponse payload) { + return Objects.isNull(payload.getBucketsList()) + ? ImmutableList.of() + : payload.getBucketsList(); + } + }; + + private static final PagedListDescriptor + LIST_SINKS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListSinksRequest injectToken(ListSinksRequest payload, String token) { + return ListSinksRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListSinksRequest injectPageSize(ListSinksRequest payload, int pageSize) { + return ListSinksRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListSinksRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListSinksResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListSinksResponse payload) { + return Objects.isNull(payload.getSinksList()) + ? ImmutableList.of() + : payload.getSinksList(); + } + }; + + private static final PagedListDescriptor< + ListExclusionsRequest, ListExclusionsResponse, LogExclusion> + LIST_EXCLUSIONS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListExclusionsRequest injectToken(ListExclusionsRequest payload, String token) { + return ListExclusionsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListExclusionsRequest injectPageSize( + ListExclusionsRequest payload, int pageSize) { + return ListExclusionsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListExclusionsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListExclusionsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListExclusionsResponse payload) { + return Objects.isNull(payload.getExclusionsList()) + ? ImmutableList.of() + : payload.getExclusionsList(); + } + }; + + private static final PagedListResponseFactory< + ListBucketsRequest, ListBucketsResponse, ListBucketsPagedResponse> + LIST_BUCKETS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListBucketsRequest, ListBucketsResponse, ListBucketsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListBucketsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_BUCKETS_PAGE_STR_DESC, request, context); + return ListBucketsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListSinksRequest, ListSinksResponse, ListSinksPagedResponse> + LIST_SINKS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListSinksRequest, ListSinksResponse, ListSinksPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListSinksRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_SINKS_PAGE_STR_DESC, request, context); + return ListSinksPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListExclusionsRequest, ListExclusionsResponse, ListExclusionsPagedResponse> + LIST_EXCLUSIONS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListExclusionsRequest, ListExclusionsResponse, ListExclusionsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListExclusionsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_EXCLUSIONS_PAGE_STR_DESC, request, context); + return ListExclusionsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to listBuckets. */ + public PagedCallSettings + listBucketsSettings() { + return listBucketsSettings; + } + + /** Returns the object with the settings used for calls to getBucket. */ + public UnaryCallSettings getBucketSettings() { + return getBucketSettings; + } + + /** Returns the object with the settings used for calls to updateBucket. */ + public UnaryCallSettings updateBucketSettings() { + return updateBucketSettings; + } + + /** Returns the object with the settings used for calls to listSinks. */ + public PagedCallSettings + listSinksSettings() { + return listSinksSettings; + } + + /** Returns the object with the settings used for calls to getSink. */ + public UnaryCallSettings getSinkSettings() { + return getSinkSettings; + } + + /** Returns the object with the settings used for calls to createSink. */ + public UnaryCallSettings createSinkSettings() { + return createSinkSettings; + } + + /** Returns the object with the settings used for calls to updateSink. */ + public UnaryCallSettings updateSinkSettings() { + return updateSinkSettings; + } + + /** Returns the object with the settings used for calls to deleteSink. */ + public UnaryCallSettings deleteSinkSettings() { + return deleteSinkSettings; + } + + /** Returns the object with the settings used for calls to listExclusions. */ + public PagedCallSettings< + ListExclusionsRequest, ListExclusionsResponse, ListExclusionsPagedResponse> + listExclusionsSettings() { + return listExclusionsSettings; + } + + /** Returns the object with the settings used for calls to getExclusion. */ + public UnaryCallSettings getExclusionSettings() { + return getExclusionSettings; + } + + /** Returns the object with the settings used for calls to createExclusion. */ + public UnaryCallSettings createExclusionSettings() { + return createExclusionSettings; + } + + /** Returns the object with the settings used for calls to updateExclusion. */ + public UnaryCallSettings updateExclusionSettings() { + return updateExclusionSettings; + } + + /** Returns the object with the settings used for calls to deleteExclusion. */ + public UnaryCallSettings deleteExclusionSettings() { + return deleteExclusionSettings; + } + + /** Returns the object with the settings used for calls to getCmekSettings. */ + public UnaryCallSettings getCmekSettingsSettings() { + return getCmekSettingsSettings; + } + + /** Returns the object with the settings used for calls to updateCmekSettings. */ + public UnaryCallSettings updateCmekSettingsSettings() { + return updateCmekSettingsSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public ConfigServiceV2Stub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcConfigServiceV2Stub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", 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 "logging.googleapis.com: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 InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().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(ConfigServiceV2StubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** 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 ConfigServiceV2StubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listBucketsSettings = settingsBuilder.listBucketsSettings().build(); + getBucketSettings = settingsBuilder.getBucketSettings().build(); + updateBucketSettings = settingsBuilder.updateBucketSettings().build(); + listSinksSettings = settingsBuilder.listSinksSettings().build(); + getSinkSettings = settingsBuilder.getSinkSettings().build(); + createSinkSettings = settingsBuilder.createSinkSettings().build(); + updateSinkSettings = settingsBuilder.updateSinkSettings().build(); + deleteSinkSettings = settingsBuilder.deleteSinkSettings().build(); + listExclusionsSettings = settingsBuilder.listExclusionsSettings().build(); + getExclusionSettings = settingsBuilder.getExclusionSettings().build(); + createExclusionSettings = settingsBuilder.createExclusionSettings().build(); + updateExclusionSettings = settingsBuilder.updateExclusionSettings().build(); + deleteExclusionSettings = settingsBuilder.deleteExclusionSettings().build(); + getCmekSettingsSettings = settingsBuilder.getCmekSettingsSettings().build(); + updateCmekSettingsSettings = settingsBuilder.updateCmekSettingsSettings().build(); + } + + /** Builder for ConfigServiceV2StubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final PagedCallSettings.Builder< + ListBucketsRequest, ListBucketsResponse, ListBucketsPagedResponse> + listBucketsSettings; + private final UnaryCallSettings.Builder getBucketSettings; + private final UnaryCallSettings.Builder updateBucketSettings; + private final PagedCallSettings.Builder< + ListSinksRequest, ListSinksResponse, ListSinksPagedResponse> + listSinksSettings; + private final UnaryCallSettings.Builder getSinkSettings; + private final UnaryCallSettings.Builder createSinkSettings; + private final UnaryCallSettings.Builder updateSinkSettings; + private final UnaryCallSettings.Builder deleteSinkSettings; + private final PagedCallSettings.Builder< + ListExclusionsRequest, ListExclusionsResponse, ListExclusionsPagedResponse> + listExclusionsSettings; + private final UnaryCallSettings.Builder getExclusionSettings; + private final UnaryCallSettings.Builder + createExclusionSettings; + private final UnaryCallSettings.Builder + updateExclusionSettings; + private final UnaryCallSettings.Builder deleteExclusionSettings; + private final UnaryCallSettings.Builder + getCmekSettingsSettings; + private final UnaryCallSettings.Builder + updateCmekSettingsSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put( + "retry_policy_3_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, + StatusCode.Code.INTERNAL, + StatusCode.Code.UNAVAILABLE))); + definitions.put( + "no_retry_4_codes", 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().setRpcTimeoutMultiplier(1.0).build(); + definitions.put("no_retry_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_3_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(Duration.ofMillis(120000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(120000L)) + .setTotalTimeout(Duration.ofMillis(120000L)) + .build(); + definitions.put("no_retry_4_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listBucketsSettings = PagedCallSettings.newBuilder(LIST_BUCKETS_PAGE_STR_FACT); + getBucketSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateBucketSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listSinksSettings = PagedCallSettings.newBuilder(LIST_SINKS_PAGE_STR_FACT); + getSinkSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createSinkSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateSinkSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteSinkSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listExclusionsSettings = PagedCallSettings.newBuilder(LIST_EXCLUSIONS_PAGE_STR_FACT); + getExclusionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createExclusionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateExclusionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteExclusionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + getCmekSettingsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateCmekSettingsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listBucketsSettings, + getBucketSettings, + updateBucketSettings, + listSinksSettings, + getSinkSettings, + createSinkSettings, + updateSinkSettings, + deleteSinkSettings, + listExclusionsSettings, + getExclusionSettings, + createExclusionSettings, + updateExclusionSettings, + deleteExclusionSettings, + getCmekSettingsSettings, + updateCmekSettingsSettings); + initDefaults(this); + } + + protected Builder(ConfigServiceV2StubSettings settings) { + super(settings); + + listBucketsSettings = settings.listBucketsSettings.toBuilder(); + getBucketSettings = settings.getBucketSettings.toBuilder(); + updateBucketSettings = settings.updateBucketSettings.toBuilder(); + listSinksSettings = settings.listSinksSettings.toBuilder(); + getSinkSettings = settings.getSinkSettings.toBuilder(); + createSinkSettings = settings.createSinkSettings.toBuilder(); + updateSinkSettings = settings.updateSinkSettings.toBuilder(); + deleteSinkSettings = settings.deleteSinkSettings.toBuilder(); + listExclusionsSettings = settings.listExclusionsSettings.toBuilder(); + getExclusionSettings = settings.getExclusionSettings.toBuilder(); + createExclusionSettings = settings.createExclusionSettings.toBuilder(); + updateExclusionSettings = settings.updateExclusionSettings.toBuilder(); + deleteExclusionSettings = settings.deleteExclusionSettings.toBuilder(); + getCmekSettingsSettings = settings.getCmekSettingsSettings.toBuilder(); + updateCmekSettingsSettings = settings.updateCmekSettingsSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listBucketsSettings, + getBucketSettings, + updateBucketSettings, + listSinksSettings, + getSinkSettings, + createSinkSettings, + updateSinkSettings, + deleteSinkSettings, + listExclusionsSettings, + getExclusionSettings, + createExclusionSettings, + updateExclusionSettings, + deleteExclusionSettings, + getCmekSettingsSettings, + updateCmekSettingsSettings); + } + + 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 + .listBucketsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .getBucketSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .updateBucketSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .listSinksSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + + builder + .getSinkSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + + builder + .createSinkSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_4_params")); + + builder + .updateSinkSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + + builder + .deleteSinkSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + + builder + .listExclusionsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + + builder + .getExclusionSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + + builder + .createExclusionSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_4_params")); + + builder + .updateExclusionSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_4_params")); + + builder + .deleteExclusionSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + + builder + .getCmekSettingsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .updateCmekSettingsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + return builder; + } + + // 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 listBuckets. */ + public PagedCallSettings.Builder< + ListBucketsRequest, ListBucketsResponse, ListBucketsPagedResponse> + listBucketsSettings() { + return listBucketsSettings; + } + + /** Returns the builder for the settings used for calls to getBucket. */ + public UnaryCallSettings.Builder getBucketSettings() { + return getBucketSettings; + } + + /** Returns the builder for the settings used for calls to updateBucket. */ + public UnaryCallSettings.Builder updateBucketSettings() { + return updateBucketSettings; + } + + /** Returns the builder for the settings used for calls to listSinks. */ + public PagedCallSettings.Builder + listSinksSettings() { + return listSinksSettings; + } + + /** Returns the builder for the settings used for calls to getSink. */ + public UnaryCallSettings.Builder getSinkSettings() { + return getSinkSettings; + } + + /** Returns the builder for the settings used for calls to createSink. */ + public UnaryCallSettings.Builder createSinkSettings() { + return createSinkSettings; + } + + /** Returns the builder for the settings used for calls to updateSink. */ + public UnaryCallSettings.Builder updateSinkSettings() { + return updateSinkSettings; + } + + /** Returns the builder for the settings used for calls to deleteSink. */ + public UnaryCallSettings.Builder deleteSinkSettings() { + return deleteSinkSettings; + } + + /** Returns the builder for the settings used for calls to listExclusions. */ + public PagedCallSettings.Builder< + ListExclusionsRequest, ListExclusionsResponse, ListExclusionsPagedResponse> + listExclusionsSettings() { + return listExclusionsSettings; + } + + /** Returns the builder for the settings used for calls to getExclusion. */ + public UnaryCallSettings.Builder getExclusionSettings() { + return getExclusionSettings; + } + + /** Returns the builder for the settings used for calls to createExclusion. */ + public UnaryCallSettings.Builder + createExclusionSettings() { + return createExclusionSettings; + } + + /** Returns the builder for the settings used for calls to updateExclusion. */ + public UnaryCallSettings.Builder + updateExclusionSettings() { + return updateExclusionSettings; + } + + /** Returns the builder for the settings used for calls to deleteExclusion. */ + public UnaryCallSettings.Builder deleteExclusionSettings() { + return deleteExclusionSettings; + } + + /** Returns the builder for the settings used for calls to getCmekSettings. */ + public UnaryCallSettings.Builder + getCmekSettingsSettings() { + return getCmekSettingsSettings; + } + + /** Returns the builder for the settings used for calls to updateCmekSettings. */ + public UnaryCallSettings.Builder + updateCmekSettingsSettings() { + return updateCmekSettingsSettings; + } + + @Override + public ConfigServiceV2StubSettings build() throws IOException { + return new ConfigServiceV2StubSettings(this); + } + } +} diff --git a/test/integration/goldens/logging/FolderLocationName.java b/test/integration/goldens/logging/FolderLocationName.java new file mode 100644 index 0000000000..526f0d1b62 --- /dev/null +++ b/test/integration/goldens/logging/FolderLocationName.java @@ -0,0 +1,186 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class FolderLocationName implements ResourceName { + private static final PathTemplate FOLDER_LOCATION = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/locations/{location}"); + private volatile Map fieldValuesMap; + private final String folder; + private final String location; + + private FolderLocationName(Builder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + + public String getFolder() { + return folder; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static FolderLocationName of(String folder, String location) { + return newBuilder().setFolder(folder).setLocation(location).build(); + } + + public static String format(String folder, String location) { + return newBuilder().setFolder(folder).setLocation(location).build().toString(); + } + + public static FolderLocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + FOLDER_LOCATION.validatedMatch( + formattedString, "FolderLocationName.parse: formattedString not in valid format"); + return of(matchMap.get("folder"), matchMap.get("location")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (FolderLocationName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return FOLDER_LOCATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(folder)) { + fieldMapBuilder.put("folder", folder); + } + if (!Objects.isNull(location)) { + fieldMapBuilder.put("location", location); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return FOLDER_LOCATION.instantiate("folder", folder); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + FolderLocationName that = ((FolderLocationName) o); + return Objects.equals(this.folder, that.folder) + && Objects.equals(this.location, that.location); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for folders/{folder}/locations/{location}. */ + public static class Builder { + private String folder; + private String location; + + private Builder() {} + + public String getFolder() { + return folder; + } + + public String getLocation() { + return location; + } + + public Builder setFolder(String folder) { + this.folder = folder; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(FolderLocationName folderLocationName) { + folder = folderLocationName.folder; + location = folderLocationName.location; + } + + public FolderLocationName build() { + return new FolderLocationName(this); + } + } +} diff --git a/test/integration/goldens/logging/FolderName.java b/test/integration/goldens/logging/FolderName.java new file mode 100644 index 0000000000..8f0c022439 --- /dev/null +++ b/test/integration/goldens/logging/FolderName.java @@ -0,0 +1,163 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class FolderName implements ResourceName { + private static final PathTemplate FOLDER = + PathTemplate.createWithoutUrlEncoding("folders/{folder}"); + private volatile Map fieldValuesMap; + private final String folder; + + private FolderName(Builder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + } + + public String getFolder() { + return folder; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static FolderName of(String folder) { + return newBuilder().setFolder(folder).build(); + } + + public static String format(String folder) { + return newBuilder().setFolder(folder).build().toString(); + } + + public static FolderName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + FOLDER.validatedMatch( + formattedString, "FolderName.parse: formattedString not in valid format"); + return of(matchMap.get("folder")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (FolderName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return FOLDER.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(folder)) { + fieldMapBuilder.put("folder", folder); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return FOLDER.instantiate("folder", folder); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + FolderName that = ((FolderName) o); + return Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + + /** Builder for folders/{folder}. */ + public static class Builder { + private String folder; + + private Builder() {} + + public String getFolder() { + return folder; + } + + public Builder setFolder(String folder) { + this.folder = folder; + return this; + } + + private Builder(FolderName folderName) { + folder = folderName.folder; + } + + public FolderName build() { + return new FolderName(this); + } + } +} diff --git a/test/integration/goldens/logging/GrpcConfigServiceV2CallableFactory.java b/test/integration/goldens/logging/GrpcConfigServiceV2CallableFactory.java new file mode 100644 index 0000000000..98b2b97776 --- /dev/null +++ b/test/integration/goldens/logging/GrpcConfigServiceV2CallableFactory.java @@ -0,0 +1,113 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC callable factory implementation for the ConfigServiceV2 service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator") +public class GrpcConfigServiceV2CallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/test/integration/goldens/logging/GrpcConfigServiceV2Stub.java b/test/integration/goldens/logging/GrpcConfigServiceV2Stub.java new file mode 100644 index 0000000000..40914d3e93 --- /dev/null +++ b/test/integration/goldens/logging/GrpcConfigServiceV2Stub.java @@ -0,0 +1,627 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.ConfigServiceV2Client.ListBucketsPagedResponse; +import static com.google.logging.v2.ConfigServiceV2Client.ListExclusionsPagedResponse; +import static com.google.logging.v2.ConfigServiceV2Client.ListSinksPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.RequestParamsExtractor; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableMap; +import com.google.logging.v2.CmekSettings; +import com.google.logging.v2.CreateExclusionRequest; +import com.google.logging.v2.CreateSinkRequest; +import com.google.logging.v2.DeleteExclusionRequest; +import com.google.logging.v2.DeleteSinkRequest; +import com.google.logging.v2.GetBucketRequest; +import com.google.logging.v2.GetCmekSettingsRequest; +import com.google.logging.v2.GetExclusionRequest; +import com.google.logging.v2.GetSinkRequest; +import com.google.logging.v2.ListBucketsRequest; +import com.google.logging.v2.ListBucketsResponse; +import com.google.logging.v2.ListExclusionsRequest; +import com.google.logging.v2.ListExclusionsResponse; +import com.google.logging.v2.ListSinksRequest; +import com.google.logging.v2.ListSinksResponse; +import com.google.logging.v2.LogBucket; +import com.google.logging.v2.LogExclusion; +import com.google.logging.v2.LogSink; +import com.google.logging.v2.UpdateBucketRequest; +import com.google.logging.v2.UpdateCmekSettingsRequest; +import com.google.logging.v2.UpdateExclusionRequest; +import com.google.logging.v2.UpdateSinkRequest; +import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the ConfigServiceV2 service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcConfigServiceV2Stub extends ConfigServiceV2Stub { + private static final MethodDescriptor + listBucketsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/ListBuckets") + .setRequestMarshaller(ProtoUtils.marshaller(ListBucketsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListBucketsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getBucketMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/GetBucket") + .setRequestMarshaller(ProtoUtils.marshaller(GetBucketRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogBucket.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + updateBucketMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/UpdateBucket") + .setRequestMarshaller(ProtoUtils.marshaller(UpdateBucketRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogBucket.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listSinksMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/ListSinks") + .setRequestMarshaller(ProtoUtils.marshaller(ListSinksRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(ListSinksResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getSinkMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/GetSink") + .setRequestMarshaller(ProtoUtils.marshaller(GetSinkRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogSink.getDefaultInstance())) + .build(); + + private static final MethodDescriptor createSinkMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/CreateSink") + .setRequestMarshaller(ProtoUtils.marshaller(CreateSinkRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogSink.getDefaultInstance())) + .build(); + + private static final MethodDescriptor updateSinkMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/UpdateSink") + .setRequestMarshaller(ProtoUtils.marshaller(UpdateSinkRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogSink.getDefaultInstance())) + .build(); + + private static final MethodDescriptor deleteSinkMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/DeleteSink") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteSinkRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listExclusionsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/ListExclusions") + .setRequestMarshaller( + ProtoUtils.marshaller(ListExclusionsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListExclusionsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + getExclusionMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/GetExclusion") + .setRequestMarshaller(ProtoUtils.marshaller(GetExclusionRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogExclusion.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + createExclusionMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/CreateExclusion") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateExclusionRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogExclusion.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + updateExclusionMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/UpdateExclusion") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateExclusionRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogExclusion.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + deleteExclusionMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/DeleteExclusion") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteExclusionRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + getCmekSettingsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/GetCmekSettings") + .setRequestMarshaller( + ProtoUtils.marshaller(GetCmekSettingsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(CmekSettings.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + updateCmekSettingsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.ConfigServiceV2/UpdateCmekSettings") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateCmekSettingsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(CmekSettings.getDefaultInstance())) + .build(); + + private final UnaryCallable listBucketsCallable; + private final UnaryCallable + listBucketsPagedCallable; + private final UnaryCallable getBucketCallable; + private final UnaryCallable updateBucketCallable; + private final UnaryCallable listSinksCallable; + private final UnaryCallable listSinksPagedCallable; + private final UnaryCallable getSinkCallable; + private final UnaryCallable createSinkCallable; + private final UnaryCallable updateSinkCallable; + private final UnaryCallable deleteSinkCallable; + private final UnaryCallable listExclusionsCallable; + private final UnaryCallable + listExclusionsPagedCallable; + private final UnaryCallable getExclusionCallable; + private final UnaryCallable createExclusionCallable; + private final UnaryCallable updateExclusionCallable; + private final UnaryCallable deleteExclusionCallable; + private final UnaryCallable getCmekSettingsCallable; + private final UnaryCallable updateCmekSettingsCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcConfigServiceV2Stub create(ConfigServiceV2StubSettings settings) + throws IOException { + return new GrpcConfigServiceV2Stub(settings, ClientContext.create(settings)); + } + + public static final GrpcConfigServiceV2Stub create(ClientContext clientContext) + throws IOException { + return new GrpcConfigServiceV2Stub( + ConfigServiceV2StubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcConfigServiceV2Stub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcConfigServiceV2Stub( + ConfigServiceV2StubSettings.newBuilder().build(), clientContext, callableFactory); + } + + protected GrpcConfigServiceV2Stub( + ConfigServiceV2StubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new GrpcConfigServiceV2CallableFactory()); + } + + protected GrpcConfigServiceV2Stub( + ConfigServiceV2StubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings listBucketsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listBucketsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListBucketsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getBucketTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getBucketMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetBucketRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings updateBucketTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateBucketMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdateBucketRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings listSinksTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listSinksMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListSinksRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getSinkTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getSinkMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetSinkRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("sink_name", String.valueOf(request.getSinkName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings createSinkTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createSinkMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(CreateSinkRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings updateSinkTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateSinkMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdateSinkRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("sink_name", String.valueOf(request.getSinkName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings deleteSinkTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteSinkMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(DeleteSinkRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("sink_name", String.valueOf(request.getSinkName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings + listExclusionsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listExclusionsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListExclusionsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getExclusionTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getExclusionMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetExclusionRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings createExclusionTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createExclusionMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(CreateExclusionRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings updateExclusionTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateExclusionMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdateExclusionRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings deleteExclusionTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteExclusionMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(DeleteExclusionRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getCmekSettingsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getCmekSettingsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetCmekSettingsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings updateCmekSettingsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateCmekSettingsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdateCmekSettingsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + + this.listBucketsCallable = + callableFactory.createUnaryCallable( + listBucketsTransportSettings, settings.listBucketsSettings(), clientContext); + this.listBucketsPagedCallable = + callableFactory.createPagedCallable( + listBucketsTransportSettings, settings.listBucketsSettings(), clientContext); + this.getBucketCallable = + callableFactory.createUnaryCallable( + getBucketTransportSettings, settings.getBucketSettings(), clientContext); + this.updateBucketCallable = + callableFactory.createUnaryCallable( + updateBucketTransportSettings, settings.updateBucketSettings(), clientContext); + this.listSinksCallable = + callableFactory.createUnaryCallable( + listSinksTransportSettings, settings.listSinksSettings(), clientContext); + this.listSinksPagedCallable = + callableFactory.createPagedCallable( + listSinksTransportSettings, settings.listSinksSettings(), clientContext); + this.getSinkCallable = + callableFactory.createUnaryCallable( + getSinkTransportSettings, settings.getSinkSettings(), clientContext); + this.createSinkCallable = + callableFactory.createUnaryCallable( + createSinkTransportSettings, settings.createSinkSettings(), clientContext); + this.updateSinkCallable = + callableFactory.createUnaryCallable( + updateSinkTransportSettings, settings.updateSinkSettings(), clientContext); + this.deleteSinkCallable = + callableFactory.createUnaryCallable( + deleteSinkTransportSettings, settings.deleteSinkSettings(), clientContext); + this.listExclusionsCallable = + callableFactory.createUnaryCallable( + listExclusionsTransportSettings, settings.listExclusionsSettings(), clientContext); + this.listExclusionsPagedCallable = + callableFactory.createPagedCallable( + listExclusionsTransportSettings, settings.listExclusionsSettings(), clientContext); + this.getExclusionCallable = + callableFactory.createUnaryCallable( + getExclusionTransportSettings, settings.getExclusionSettings(), clientContext); + this.createExclusionCallable = + callableFactory.createUnaryCallable( + createExclusionTransportSettings, settings.createExclusionSettings(), clientContext); + this.updateExclusionCallable = + callableFactory.createUnaryCallable( + updateExclusionTransportSettings, settings.updateExclusionSettings(), clientContext); + this.deleteExclusionCallable = + callableFactory.createUnaryCallable( + deleteExclusionTransportSettings, settings.deleteExclusionSettings(), clientContext); + this.getCmekSettingsCallable = + callableFactory.createUnaryCallable( + getCmekSettingsTransportSettings, settings.getCmekSettingsSettings(), clientContext); + this.updateCmekSettingsCallable = + callableFactory.createUnaryCallable( + updateCmekSettingsTransportSettings, + settings.updateCmekSettingsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + public UnaryCallable listBucketsCallable() { + return listBucketsCallable; + } + + public UnaryCallable listBucketsPagedCallable() { + return listBucketsPagedCallable; + } + + public UnaryCallable getBucketCallable() { + return getBucketCallable; + } + + public UnaryCallable updateBucketCallable() { + return updateBucketCallable; + } + + public UnaryCallable listSinksCallable() { + return listSinksCallable; + } + + public UnaryCallable listSinksPagedCallable() { + return listSinksPagedCallable; + } + + public UnaryCallable getSinkCallable() { + return getSinkCallable; + } + + public UnaryCallable createSinkCallable() { + return createSinkCallable; + } + + public UnaryCallable updateSinkCallable() { + return updateSinkCallable; + } + + public UnaryCallable deleteSinkCallable() { + return deleteSinkCallable; + } + + public UnaryCallable listExclusionsCallable() { + return listExclusionsCallable; + } + + public UnaryCallable + listExclusionsPagedCallable() { + return listExclusionsPagedCallable; + } + + public UnaryCallable getExclusionCallable() { + return getExclusionCallable; + } + + public UnaryCallable createExclusionCallable() { + return createExclusionCallable; + } + + public UnaryCallable updateExclusionCallable() { + return updateExclusionCallable; + } + + public UnaryCallable deleteExclusionCallable() { + return deleteExclusionCallable; + } + + public UnaryCallable getCmekSettingsCallable() { + return getCmekSettingsCallable; + } + + public UnaryCallable updateCmekSettingsCallable() { + return updateCmekSettingsCallable; + } + + @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/test/integration/goldens/logging/GrpcLoggingServiceV2CallableFactory.java b/test/integration/goldens/logging/GrpcLoggingServiceV2CallableFactory.java new file mode 100644 index 0000000000..e28e2e738f --- /dev/null +++ b/test/integration/goldens/logging/GrpcLoggingServiceV2CallableFactory.java @@ -0,0 +1,113 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC callable factory implementation for the LoggingServiceV2 service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator") +public class GrpcLoggingServiceV2CallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/test/integration/goldens/logging/GrpcLoggingServiceV2Stub.java b/test/integration/goldens/logging/GrpcLoggingServiceV2Stub.java new file mode 100644 index 0000000000..fd4bc1d3a1 --- /dev/null +++ b/test/integration/goldens/logging/GrpcLoggingServiceV2Stub.java @@ -0,0 +1,310 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.LoggingServiceV2Client.ListLogEntriesPagedResponse; +import static com.google.logging.v2.LoggingServiceV2Client.ListLogsPagedResponse; +import static com.google.logging.v2.LoggingServiceV2Client.ListMonitoredResourceDescriptorsPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.RequestParamsExtractor; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableMap; +import com.google.logging.v2.DeleteLogRequest; +import com.google.logging.v2.ListLogEntriesRequest; +import com.google.logging.v2.ListLogEntriesResponse; +import com.google.logging.v2.ListLogsRequest; +import com.google.logging.v2.ListLogsResponse; +import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest; +import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse; +import com.google.logging.v2.WriteLogEntriesRequest; +import com.google.logging.v2.WriteLogEntriesResponse; +import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the LoggingServiceV2 service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub { + private static final MethodDescriptor deleteLogMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.LoggingServiceV2/DeleteLog") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteLogRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + writeLogEntriesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.LoggingServiceV2/WriteLogEntries") + .setRequestMarshaller( + ProtoUtils.marshaller(WriteLogEntriesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(WriteLogEntriesResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listLogEntriesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.LoggingServiceV2/ListLogEntries") + .setRequestMarshaller( + ProtoUtils.marshaller(ListLogEntriesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListLogEntriesResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> + listMonitoredResourceDescriptorsMethodDescriptor = + MethodDescriptor + . + newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.logging.v2.LoggingServiceV2/ListMonitoredResourceDescriptors") + .setRequestMarshaller( + ProtoUtils.marshaller( + ListMonitoredResourceDescriptorsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller( + ListMonitoredResourceDescriptorsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listLogsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.LoggingServiceV2/ListLogs") + .setRequestMarshaller(ProtoUtils.marshaller(ListLogsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(ListLogsResponse.getDefaultInstance())) + .build(); + + private final UnaryCallable deleteLogCallable; + private final UnaryCallable + writeLogEntriesCallable; + private final UnaryCallable listLogEntriesCallable; + private final UnaryCallable + listLogEntriesPagedCallable; + private final UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> + listMonitoredResourceDescriptorsCallable; + private final UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsPagedCallable; + private final UnaryCallable listLogsCallable; + private final UnaryCallable listLogsPagedCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcLoggingServiceV2Stub create(LoggingServiceV2StubSettings settings) + throws IOException { + return new GrpcLoggingServiceV2Stub(settings, ClientContext.create(settings)); + } + + public static final GrpcLoggingServiceV2Stub create(ClientContext clientContext) + throws IOException { + return new GrpcLoggingServiceV2Stub( + LoggingServiceV2StubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcLoggingServiceV2Stub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcLoggingServiceV2Stub( + LoggingServiceV2StubSettings.newBuilder().build(), clientContext, callableFactory); + } + + protected GrpcLoggingServiceV2Stub( + LoggingServiceV2StubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new GrpcLoggingServiceV2CallableFactory()); + } + + protected GrpcLoggingServiceV2Stub( + LoggingServiceV2StubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings deleteLogTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteLogMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(DeleteLogRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("log_name", String.valueOf(request.getLogName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings + writeLogEntriesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(writeLogEntriesMethodDescriptor) + .build(); + GrpcCallSettings + listLogEntriesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listLogEntriesMethodDescriptor) + .build(); + GrpcCallSettings< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> + listMonitoredResourceDescriptorsTransportSettings = + GrpcCallSettings + . + newBuilder() + .setMethodDescriptor(listMonitoredResourceDescriptorsMethodDescriptor) + .build(); + GrpcCallSettings listLogsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listLogsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListLogsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + + this.deleteLogCallable = + callableFactory.createUnaryCallable( + deleteLogTransportSettings, settings.deleteLogSettings(), clientContext); + this.writeLogEntriesCallable = + callableFactory.createUnaryCallable( + writeLogEntriesTransportSettings, settings.writeLogEntriesSettings(), clientContext); + this.listLogEntriesCallable = + callableFactory.createUnaryCallable( + listLogEntriesTransportSettings, settings.listLogEntriesSettings(), clientContext); + this.listLogEntriesPagedCallable = + callableFactory.createPagedCallable( + listLogEntriesTransportSettings, settings.listLogEntriesSettings(), clientContext); + this.listMonitoredResourceDescriptorsCallable = + callableFactory.createUnaryCallable( + listMonitoredResourceDescriptorsTransportSettings, + settings.listMonitoredResourceDescriptorsSettings(), + clientContext); + this.listMonitoredResourceDescriptorsPagedCallable = + callableFactory.createPagedCallable( + listMonitoredResourceDescriptorsTransportSettings, + settings.listMonitoredResourceDescriptorsSettings(), + clientContext); + this.listLogsCallable = + callableFactory.createUnaryCallable( + listLogsTransportSettings, settings.listLogsSettings(), clientContext); + this.listLogsPagedCallable = + callableFactory.createPagedCallable( + listLogsTransportSettings, settings.listLogsSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + public UnaryCallable deleteLogCallable() { + return deleteLogCallable; + } + + public UnaryCallable writeLogEntriesCallable() { + return writeLogEntriesCallable; + } + + public UnaryCallable listLogEntriesCallable() { + return listLogEntriesCallable; + } + + public UnaryCallable + listLogEntriesPagedCallable() { + return listLogEntriesPagedCallable; + } + + public UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> + listMonitoredResourceDescriptorsCallable() { + return listMonitoredResourceDescriptorsCallable; + } + + public UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsPagedCallable() { + return listMonitoredResourceDescriptorsPagedCallable; + } + + public UnaryCallable listLogsCallable() { + return listLogsCallable; + } + + public UnaryCallable listLogsPagedCallable() { + return listLogsPagedCallable; + } + + @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/test/integration/goldens/logging/GrpcMetricsServiceV2CallableFactory.java b/test/integration/goldens/logging/GrpcMetricsServiceV2CallableFactory.java new file mode 100644 index 0000000000..f75129947e --- /dev/null +++ b/test/integration/goldens/logging/GrpcMetricsServiceV2CallableFactory.java @@ -0,0 +1,113 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC callable factory implementation for the MetricsServiceV2 service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator") +public class GrpcMetricsServiceV2CallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/test/integration/goldens/logging/GrpcMetricsServiceV2Stub.java b/test/integration/goldens/logging/GrpcMetricsServiceV2Stub.java new file mode 100644 index 0000000000..c0c882c2d0 --- /dev/null +++ b/test/integration/goldens/logging/GrpcMetricsServiceV2Stub.java @@ -0,0 +1,293 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.MetricsServiceV2Client.ListLogMetricsPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.RequestParamsExtractor; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableMap; +import com.google.logging.v2.CreateLogMetricRequest; +import com.google.logging.v2.DeleteLogMetricRequest; +import com.google.logging.v2.GetLogMetricRequest; +import com.google.logging.v2.ListLogMetricsRequest; +import com.google.logging.v2.ListLogMetricsResponse; +import com.google.logging.v2.LogMetric; +import com.google.logging.v2.UpdateLogMetricRequest; +import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the MetricsServiceV2 service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcMetricsServiceV2Stub extends MetricsServiceV2Stub { + private static final MethodDescriptor + listLogMetricsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.MetricsServiceV2/ListLogMetrics") + .setRequestMarshaller( + ProtoUtils.marshaller(ListLogMetricsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListLogMetricsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + getLogMetricMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.MetricsServiceV2/GetLogMetric") + .setRequestMarshaller(ProtoUtils.marshaller(GetLogMetricRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogMetric.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + createLogMetricMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.MetricsServiceV2/CreateLogMetric") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateLogMetricRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogMetric.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + updateLogMetricMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.MetricsServiceV2/UpdateLogMetric") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateLogMetricRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LogMetric.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + deleteLogMetricMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.logging.v2.MetricsServiceV2/DeleteLogMetric") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteLogMetricRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private final UnaryCallable listLogMetricsCallable; + private final UnaryCallable + listLogMetricsPagedCallable; + private final UnaryCallable getLogMetricCallable; + private final UnaryCallable createLogMetricCallable; + private final UnaryCallable updateLogMetricCallable; + private final UnaryCallable deleteLogMetricCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcMetricsServiceV2Stub create(MetricsServiceV2StubSettings settings) + throws IOException { + return new GrpcMetricsServiceV2Stub(settings, ClientContext.create(settings)); + } + + public static final GrpcMetricsServiceV2Stub create(ClientContext clientContext) + throws IOException { + return new GrpcMetricsServiceV2Stub( + MetricsServiceV2StubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcMetricsServiceV2Stub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcMetricsServiceV2Stub( + MetricsServiceV2StubSettings.newBuilder().build(), clientContext, callableFactory); + } + + protected GrpcMetricsServiceV2Stub( + MetricsServiceV2StubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new GrpcMetricsServiceV2CallableFactory()); + } + + protected GrpcMetricsServiceV2Stub( + MetricsServiceV2StubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings + listLogMetricsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listLogMetricsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListLogMetricsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getLogMetricTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getLogMetricMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetLogMetricRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("metric_name", String.valueOf(request.getMetricName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings createLogMetricTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createLogMetricMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(CreateLogMetricRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings updateLogMetricTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateLogMetricMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdateLogMetricRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("metric_name", String.valueOf(request.getMetricName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings deleteLogMetricTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteLogMetricMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(DeleteLogMetricRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("metric_name", String.valueOf(request.getMetricName())); + return params.build(); + } + }) + .build(); + + this.listLogMetricsCallable = + callableFactory.createUnaryCallable( + listLogMetricsTransportSettings, settings.listLogMetricsSettings(), clientContext); + this.listLogMetricsPagedCallable = + callableFactory.createPagedCallable( + listLogMetricsTransportSettings, settings.listLogMetricsSettings(), clientContext); + this.getLogMetricCallable = + callableFactory.createUnaryCallable( + getLogMetricTransportSettings, settings.getLogMetricSettings(), clientContext); + this.createLogMetricCallable = + callableFactory.createUnaryCallable( + createLogMetricTransportSettings, settings.createLogMetricSettings(), clientContext); + this.updateLogMetricCallable = + callableFactory.createUnaryCallable( + updateLogMetricTransportSettings, settings.updateLogMetricSettings(), clientContext); + this.deleteLogMetricCallable = + callableFactory.createUnaryCallable( + deleteLogMetricTransportSettings, settings.deleteLogMetricSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + public UnaryCallable listLogMetricsCallable() { + return listLogMetricsCallable; + } + + public UnaryCallable + listLogMetricsPagedCallable() { + return listLogMetricsPagedCallable; + } + + public UnaryCallable getLogMetricCallable() { + return getLogMetricCallable; + } + + public UnaryCallable createLogMetricCallable() { + return createLogMetricCallable; + } + + public UnaryCallable updateLogMetricCallable() { + return updateLogMetricCallable; + } + + public UnaryCallable deleteLogMetricCallable() { + return deleteLogMetricCallable; + } + + @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/test/integration/goldens/logging/LocationName.java b/test/integration/goldens/logging/LocationName.java new file mode 100644 index 0000000000..9074b6586d --- /dev/null +++ b/test/integration/goldens/logging/LocationName.java @@ -0,0 +1,186 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LocationName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION = + PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + + private LocationName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LocationName of(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build(); + } + + public static String format(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build().toString(); + } + + public static LocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION.validatedMatch( + formattedString, "LocationName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LocationName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } + if (!Objects.isNull(location)) { + fieldMapBuilder.put("location", location); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION.instantiate("project", project); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LocationName that = ((LocationName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for projects/{project}/locations/{location}. */ + public static class Builder { + private String project; + private String location; + + private Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(LocationName locationName) { + project = locationName.project; + location = locationName.location; + } + + public LocationName build() { + return new LocationName(this); + } + } +} diff --git a/test/integration/goldens/logging/LogBucketName.java b/test/integration/goldens/logging/LogBucketName.java new file mode 100644 index 0000000000..cb94fab601 --- /dev/null +++ b/test/integration/goldens/logging/LogBucketName.java @@ -0,0 +1,540 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LogBucketName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION_BUCKET = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/locations/{location}/buckets/{bucket}"); + private static final PathTemplate ORGANIZATION_LOCATION_BUCKET = + PathTemplate.createWithoutUrlEncoding( + "organizations/{organization}/locations/{location}/buckets/{bucket}"); + private static final PathTemplate FOLDER_LOCATION_BUCKET = + PathTemplate.createWithoutUrlEncoding( + "folders/{folder}/locations/{location}/buckets/{bucket}"); + private static final PathTemplate BILLING_ACCOUNT_LOCATION_BUCKET = + PathTemplate.createWithoutUrlEncoding( + "billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}"); + private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; + private final String project; + private final String location; + private final String bucket; + private final String organization; + private final String folder; + private final String billingAccount; + + private LogBucketName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + bucket = Preconditions.checkNotNull(builder.getBucket()); + organization = null; + folder = null; + billingAccount = null; + pathTemplate = PROJECT_LOCATION_BUCKET; + } + + private LogBucketName(OrganizationLocationBucketBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + location = Preconditions.checkNotNull(builder.getLocation()); + bucket = Preconditions.checkNotNull(builder.getBucket()); + project = null; + folder = null; + billingAccount = null; + pathTemplate = ORGANIZATION_LOCATION_BUCKET; + } + + private LogBucketName(FolderLocationBucketBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + location = Preconditions.checkNotNull(builder.getLocation()); + bucket = Preconditions.checkNotNull(builder.getBucket()); + project = null; + organization = null; + billingAccount = null; + pathTemplate = FOLDER_LOCATION_BUCKET; + } + + private LogBucketName(BillingAccountLocationBucketBuilder builder) { + billingAccount = Preconditions.checkNotNull(builder.getBillingAccount()); + location = Preconditions.checkNotNull(builder.getLocation()); + bucket = Preconditions.checkNotNull(builder.getBucket()); + project = null; + organization = null; + folder = null; + pathTemplate = BILLING_ACCOUNT_LOCATION_BUCKET; + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getBucket() { + return bucket; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; + } + + public String getBillingAccount() { + return billingAccount; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectLocationBucketBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationLocationBucketBuilder newOrganizationLocationBucketBuilder() { + return new OrganizationLocationBucketBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderLocationBucketBuilder newFolderLocationBucketBuilder() { + return new FolderLocationBucketBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static BillingAccountLocationBucketBuilder newBillingAccountLocationBucketBuilder() { + return new BillingAccountLocationBucketBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LogBucketName of(String project, String location, String bucket) { + return newBuilder().setProject(project).setLocation(location).setBucket(bucket).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogBucketName ofProjectLocationBucketName( + String project, String location, String bucket) { + return newBuilder().setProject(project).setLocation(location).setBucket(bucket).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogBucketName ofOrganizationLocationBucketName( + String organization, String location, String bucket) { + return newOrganizationLocationBucketBuilder() + .setOrganization(organization) + .setLocation(location) + .setBucket(bucket) + .build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogBucketName ofFolderLocationBucketName( + String folder, String location, String bucket) { + return newFolderLocationBucketBuilder() + .setFolder(folder) + .setLocation(location) + .setBucket(bucket) + .build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogBucketName ofBillingAccountLocationBucketName( + String billingAccount, String location, String bucket) { + return newBillingAccountLocationBucketBuilder() + .setBillingAccount(billingAccount) + .setLocation(location) + .setBucket(bucket) + .build(); + } + + public static String format(String project, String location, String bucket) { + return newBuilder() + .setProject(project) + .setLocation(location) + .setBucket(bucket) + .build() + .toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectLocationBucketName( + String project, String location, String bucket) { + return newBuilder() + .setProject(project) + .setLocation(location) + .setBucket(bucket) + .build() + .toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationLocationBucketName( + String organization, String location, String bucket) { + return newOrganizationLocationBucketBuilder() + .setOrganization(organization) + .setLocation(location) + .setBucket(bucket) + .build() + .toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderLocationBucketName( + String folder, String location, String bucket) { + return newFolderLocationBucketBuilder() + .setFolder(folder) + .setLocation(location) + .setBucket(bucket) + .build() + .toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatBillingAccountLocationBucketName( + String billingAccount, String location, String bucket) { + return newBillingAccountLocationBucketBuilder() + .setBillingAccount(billingAccount) + .setLocation(location) + .setBucket(bucket) + .build() + .toString(); + } + + public static LogBucketName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + if (PROJECT_LOCATION_BUCKET.matches(formattedString)) { + Map matchMap = PROJECT_LOCATION_BUCKET.match(formattedString); + return ofProjectLocationBucketName( + matchMap.get("project"), matchMap.get("location"), matchMap.get("bucket")); + } else if (ORGANIZATION_LOCATION_BUCKET.matches(formattedString)) { + Map matchMap = ORGANIZATION_LOCATION_BUCKET.match(formattedString); + return ofOrganizationLocationBucketName( + matchMap.get("organization"), matchMap.get("location"), matchMap.get("bucket")); + } else if (FOLDER_LOCATION_BUCKET.matches(formattedString)) { + Map matchMap = FOLDER_LOCATION_BUCKET.match(formattedString); + return ofFolderLocationBucketName( + matchMap.get("folder"), matchMap.get("location"), matchMap.get("bucket")); + } else if (BILLING_ACCOUNT_LOCATION_BUCKET.matches(formattedString)) { + Map matchMap = BILLING_ACCOUNT_LOCATION_BUCKET.match(formattedString); + return ofBillingAccountLocationBucketName( + matchMap.get("billing_account"), matchMap.get("location"), matchMap.get("bucket")); + } + throw new ValidationException("LogBucketName.parse: formattedString not in valid format"); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LogBucketName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION_BUCKET.matches(formattedString) + || ORGANIZATION_LOCATION_BUCKET.matches(formattedString) + || FOLDER_LOCATION_BUCKET.matches(formattedString) + || BILLING_ACCOUNT_LOCATION_BUCKET.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } + if (!Objects.isNull(location)) { + fieldMapBuilder.put("location", location); + } + if (!Objects.isNull(bucket)) { + fieldMapBuilder.put("bucket", bucket); + } + if (!Objects.isNull(organization)) { + fieldMapBuilder.put("organization", organization); + } + if (!Objects.isNull(folder)) { + fieldMapBuilder.put("folder", folder); + } + if (!Objects.isNull(billingAccount)) { + fieldMapBuilder.put("billing_account", billingAccount); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LogBucketName that = ((LogBucketName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.bucket, that.bucket) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder) + && Objects.equals(this.billingAccount, that.billingAccount); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(bucket); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(billingAccount); + return h; + } + + /** Builder for projects/{project}/locations/{location}/buckets/{bucket}. */ + public static class Builder { + private String project; + private String location; + private String bucket; + + private Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getBucket() { + return bucket; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setBucket(String bucket) { + this.bucket = bucket; + return this; + } + + private Builder(LogBucketName logBucketName) { + Preconditions.checkArgument( + Objects.equals(logBucketName.pathTemplate, PROJECT_LOCATION_BUCKET), + "toBuilder is only supported when LogBucketName has the pattern of projects/{project}/locations/{location}/buckets/{bucket}"); + project = logBucketName.project; + location = logBucketName.location; + bucket = logBucketName.bucket; + } + + public LogBucketName build() { + return new LogBucketName(this); + } + } + + /** Builder for organizations/{organization}/locations/{location}/buckets/{bucket}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationLocationBucketBuilder { + private String organization; + private String location; + private String bucket; + + private OrganizationLocationBucketBuilder() {} + + public String getOrganization() { + return organization; + } + + public String getLocation() { + return location; + } + + public String getBucket() { + return bucket; + } + + public OrganizationLocationBucketBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public OrganizationLocationBucketBuilder setLocation(String location) { + this.location = location; + return this; + } + + public OrganizationLocationBucketBuilder setBucket(String bucket) { + this.bucket = bucket; + return this; + } + + public LogBucketName build() { + return new LogBucketName(this); + } + } + + /** Builder for folders/{folder}/locations/{location}/buckets/{bucket}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderLocationBucketBuilder { + private String folder; + private String location; + private String bucket; + + private FolderLocationBucketBuilder() {} + + public String getFolder() { + return folder; + } + + public String getLocation() { + return location; + } + + public String getBucket() { + return bucket; + } + + public FolderLocationBucketBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public FolderLocationBucketBuilder setLocation(String location) { + this.location = location; + return this; + } + + public FolderLocationBucketBuilder setBucket(String bucket) { + this.bucket = bucket; + return this; + } + + public LogBucketName build() { + return new LogBucketName(this); + } + } + + /** Builder for billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class BillingAccountLocationBucketBuilder { + private String billingAccount; + private String location; + private String bucket; + + private BillingAccountLocationBucketBuilder() {} + + public String getBillingAccount() { + return billingAccount; + } + + public String getLocation() { + return location; + } + + public String getBucket() { + return bucket; + } + + public BillingAccountLocationBucketBuilder setBillingAccount(String billingAccount) { + this.billingAccount = billingAccount; + return this; + } + + public BillingAccountLocationBucketBuilder setLocation(String location) { + this.location = location; + return this; + } + + public BillingAccountLocationBucketBuilder setBucket(String bucket) { + this.bucket = bucket; + return this; + } + + public LogBucketName build() { + return new LogBucketName(this); + } + } +} diff --git a/test/integration/goldens/logging/LogExclusionName.java b/test/integration/goldens/logging/LogExclusionName.java new file mode 100644 index 0000000000..8c0bc46049 --- /dev/null +++ b/test/integration/goldens/logging/LogExclusionName.java @@ -0,0 +1,449 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LogExclusionName implements ResourceName { + private static final PathTemplate PROJECT_EXCLUSION = + PathTemplate.createWithoutUrlEncoding("projects/{project}/exclusions/{exclusion}"); + private static final PathTemplate ORGANIZATION_EXCLUSION = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}/exclusions/{exclusion}"); + private static final PathTemplate FOLDER_EXCLUSION = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/exclusions/{exclusion}"); + private static final PathTemplate BILLING_ACCOUNT_EXCLUSION = + PathTemplate.createWithoutUrlEncoding( + "billingAccounts/{billing_account}/exclusions/{exclusion}"); + private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; + private final String project; + private final String exclusion; + private final String organization; + private final String folder; + private final String billingAccount; + + private LogExclusionName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + exclusion = Preconditions.checkNotNull(builder.getExclusion()); + organization = null; + folder = null; + billingAccount = null; + pathTemplate = PROJECT_EXCLUSION; + } + + private LogExclusionName(OrganizationExclusionBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + exclusion = Preconditions.checkNotNull(builder.getExclusion()); + project = null; + folder = null; + billingAccount = null; + pathTemplate = ORGANIZATION_EXCLUSION; + } + + private LogExclusionName(FolderExclusionBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + exclusion = Preconditions.checkNotNull(builder.getExclusion()); + project = null; + organization = null; + billingAccount = null; + pathTemplate = FOLDER_EXCLUSION; + } + + private LogExclusionName(BillingAccountExclusionBuilder builder) { + billingAccount = Preconditions.checkNotNull(builder.getBillingAccount()); + exclusion = Preconditions.checkNotNull(builder.getExclusion()); + project = null; + organization = null; + folder = null; + pathTemplate = BILLING_ACCOUNT_EXCLUSION; + } + + public String getProject() { + return project; + } + + public String getExclusion() { + return exclusion; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; + } + + public String getBillingAccount() { + return billingAccount; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectExclusionBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationExclusionBuilder newOrganizationExclusionBuilder() { + return new OrganizationExclusionBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderExclusionBuilder newFolderExclusionBuilder() { + return new FolderExclusionBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static BillingAccountExclusionBuilder newBillingAccountExclusionBuilder() { + return new BillingAccountExclusionBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LogExclusionName of(String project, String exclusion) { + return newBuilder().setProject(project).setExclusion(exclusion).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogExclusionName ofProjectExclusionName(String project, String exclusion) { + return newBuilder().setProject(project).setExclusion(exclusion).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogExclusionName ofOrganizationExclusionName( + String organization, String exclusion) { + return newOrganizationExclusionBuilder() + .setOrganization(organization) + .setExclusion(exclusion) + .build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogExclusionName ofFolderExclusionName(String folder, String exclusion) { + return newFolderExclusionBuilder().setFolder(folder).setExclusion(exclusion).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogExclusionName ofBillingAccountExclusionName( + String billingAccount, String exclusion) { + return newBillingAccountExclusionBuilder() + .setBillingAccount(billingAccount) + .setExclusion(exclusion) + .build(); + } + + public static String format(String project, String exclusion) { + return newBuilder().setProject(project).setExclusion(exclusion).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectExclusionName(String project, String exclusion) { + return newBuilder().setProject(project).setExclusion(exclusion).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationExclusionName(String organization, String exclusion) { + return newOrganizationExclusionBuilder() + .setOrganization(organization) + .setExclusion(exclusion) + .build() + .toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderExclusionName(String folder, String exclusion) { + return newFolderExclusionBuilder().setFolder(folder).setExclusion(exclusion).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatBillingAccountExclusionName(String billingAccount, String exclusion) { + return newBillingAccountExclusionBuilder() + .setBillingAccount(billingAccount) + .setExclusion(exclusion) + .build() + .toString(); + } + + public static LogExclusionName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + if (PROJECT_EXCLUSION.matches(formattedString)) { + Map matchMap = PROJECT_EXCLUSION.match(formattedString); + return ofProjectExclusionName(matchMap.get("project"), matchMap.get("exclusion")); + } else if (ORGANIZATION_EXCLUSION.matches(formattedString)) { + Map matchMap = ORGANIZATION_EXCLUSION.match(formattedString); + return ofOrganizationExclusionName(matchMap.get("organization"), matchMap.get("exclusion")); + } else if (FOLDER_EXCLUSION.matches(formattedString)) { + Map matchMap = FOLDER_EXCLUSION.match(formattedString); + return ofFolderExclusionName(matchMap.get("folder"), matchMap.get("exclusion")); + } else if (BILLING_ACCOUNT_EXCLUSION.matches(formattedString)) { + Map matchMap = BILLING_ACCOUNT_EXCLUSION.match(formattedString); + return ofBillingAccountExclusionName( + matchMap.get("billing_account"), matchMap.get("exclusion")); + } + throw new ValidationException("LogExclusionName.parse: formattedString not in valid format"); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LogExclusionName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_EXCLUSION.matches(formattedString) + || ORGANIZATION_EXCLUSION.matches(formattedString) + || FOLDER_EXCLUSION.matches(formattedString) + || BILLING_ACCOUNT_EXCLUSION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } + if (!Objects.isNull(exclusion)) { + fieldMapBuilder.put("exclusion", exclusion); + } + if (!Objects.isNull(organization)) { + fieldMapBuilder.put("organization", organization); + } + if (!Objects.isNull(folder)) { + fieldMapBuilder.put("folder", folder); + } + if (!Objects.isNull(billingAccount)) { + fieldMapBuilder.put("billing_account", billingAccount); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LogExclusionName that = ((LogExclusionName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.exclusion, that.exclusion) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder) + && Objects.equals(this.billingAccount, that.billingAccount); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(exclusion); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(billingAccount); + return h; + } + + /** Builder for projects/{project}/exclusions/{exclusion}. */ + public static class Builder { + private String project; + private String exclusion; + + private Builder() {} + + public String getProject() { + return project; + } + + public String getExclusion() { + return exclusion; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setExclusion(String exclusion) { + this.exclusion = exclusion; + return this; + } + + private Builder(LogExclusionName logExclusionName) { + Preconditions.checkArgument( + Objects.equals(logExclusionName.pathTemplate, PROJECT_EXCLUSION), + "toBuilder is only supported when LogExclusionName has the pattern of projects/{project}/exclusions/{exclusion}"); + project = logExclusionName.project; + exclusion = logExclusionName.exclusion; + } + + public LogExclusionName build() { + return new LogExclusionName(this); + } + } + + /** Builder for organizations/{organization}/exclusions/{exclusion}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationExclusionBuilder { + private String organization; + private String exclusion; + + private OrganizationExclusionBuilder() {} + + public String getOrganization() { + return organization; + } + + public String getExclusion() { + return exclusion; + } + + public OrganizationExclusionBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public OrganizationExclusionBuilder setExclusion(String exclusion) { + this.exclusion = exclusion; + return this; + } + + public LogExclusionName build() { + return new LogExclusionName(this); + } + } + + /** Builder for folders/{folder}/exclusions/{exclusion}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderExclusionBuilder { + private String folder; + private String exclusion; + + private FolderExclusionBuilder() {} + + public String getFolder() { + return folder; + } + + public String getExclusion() { + return exclusion; + } + + public FolderExclusionBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public FolderExclusionBuilder setExclusion(String exclusion) { + this.exclusion = exclusion; + return this; + } + + public LogExclusionName build() { + return new LogExclusionName(this); + } + } + + /** Builder for billingAccounts/{billing_account}/exclusions/{exclusion}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class BillingAccountExclusionBuilder { + private String billingAccount; + private String exclusion; + + private BillingAccountExclusionBuilder() {} + + public String getBillingAccount() { + return billingAccount; + } + + public String getExclusion() { + return exclusion; + } + + public BillingAccountExclusionBuilder setBillingAccount(String billingAccount) { + this.billingAccount = billingAccount; + return this; + } + + public BillingAccountExclusionBuilder setExclusion(String exclusion) { + this.exclusion = exclusion; + return this; + } + + public LogExclusionName build() { + return new LogExclusionName(this); + } + } +} diff --git a/test/integration/goldens/logging/LogMetricName.java b/test/integration/goldens/logging/LogMetricName.java new file mode 100644 index 0000000000..104ecc3266 --- /dev/null +++ b/test/integration/goldens/logging/LogMetricName.java @@ -0,0 +1,185 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LogMetricName implements ResourceName { + private static final PathTemplate PROJECT_METRIC = + PathTemplate.createWithoutUrlEncoding("projects/{project}/metrics/{metric}"); + private volatile Map fieldValuesMap; + private final String project; + private final String metric; + + private LogMetricName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + metric = Preconditions.checkNotNull(builder.getMetric()); + } + + public String getProject() { + return project; + } + + public String getMetric() { + return metric; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LogMetricName of(String project, String metric) { + return newBuilder().setProject(project).setMetric(metric).build(); + } + + public static String format(String project, String metric) { + return newBuilder().setProject(project).setMetric(metric).build().toString(); + } + + public static LogMetricName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_METRIC.validatedMatch( + formattedString, "LogMetricName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("metric")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LogMetricName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_METRIC.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } + if (!Objects.isNull(metric)) { + fieldMapBuilder.put("metric", metric); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_METRIC.instantiate("project", project); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LogMetricName that = ((LogMetricName) o); + return Objects.equals(this.project, that.project) && Objects.equals(this.metric, that.metric); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(metric); + return h; + } + + /** Builder for projects/{project}/metrics/{metric}. */ + public static class Builder { + private String project; + private String metric; + + private Builder() {} + + public String getProject() { + return project; + } + + public String getMetric() { + return metric; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setMetric(String metric) { + this.metric = metric; + return this; + } + + private Builder(LogMetricName logMetricName) { + project = logMetricName.project; + metric = logMetricName.metric; + } + + public LogMetricName build() { + return new LogMetricName(this); + } + } +} diff --git a/test/integration/goldens/logging/LogName.java b/test/integration/goldens/logging/LogName.java new file mode 100644 index 0000000000..b4f4cea34e --- /dev/null +++ b/test/integration/goldens/logging/LogName.java @@ -0,0 +1,435 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LogName implements ResourceName { + private static final PathTemplate PROJECT_LOG = + PathTemplate.createWithoutUrlEncoding("projects/{project}/logs/{log}"); + private static final PathTemplate ORGANIZATION_LOG = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}/logs/{log}"); + private static final PathTemplate FOLDER_LOG = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/logs/{log}"); + private static final PathTemplate BILLING_ACCOUNT_LOG = + PathTemplate.createWithoutUrlEncoding("billingAccounts/{billing_account}/logs/{log}"); + private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; + private final String project; + private final String log; + private final String organization; + private final String folder; + private final String billingAccount; + + private LogName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + log = Preconditions.checkNotNull(builder.getLog()); + organization = null; + folder = null; + billingAccount = null; + pathTemplate = PROJECT_LOG; + } + + private LogName(OrganizationLogBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + log = Preconditions.checkNotNull(builder.getLog()); + project = null; + folder = null; + billingAccount = null; + pathTemplate = ORGANIZATION_LOG; + } + + private LogName(FolderLogBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + log = Preconditions.checkNotNull(builder.getLog()); + project = null; + organization = null; + billingAccount = null; + pathTemplate = FOLDER_LOG; + } + + private LogName(BillingAccountLogBuilder builder) { + billingAccount = Preconditions.checkNotNull(builder.getBillingAccount()); + log = Preconditions.checkNotNull(builder.getLog()); + project = null; + organization = null; + folder = null; + pathTemplate = BILLING_ACCOUNT_LOG; + } + + public String getProject() { + return project; + } + + public String getLog() { + return log; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; + } + + public String getBillingAccount() { + return billingAccount; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectLogBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationLogBuilder newOrganizationLogBuilder() { + return new OrganizationLogBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderLogBuilder newFolderLogBuilder() { + return new FolderLogBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static BillingAccountLogBuilder newBillingAccountLogBuilder() { + return new BillingAccountLogBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LogName of(String project, String log) { + return newBuilder().setProject(project).setLog(log).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogName ofProjectLogName(String project, String log) { + return newBuilder().setProject(project).setLog(log).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogName ofOrganizationLogName(String organization, String log) { + return newOrganizationLogBuilder().setOrganization(organization).setLog(log).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogName ofFolderLogName(String folder, String log) { + return newFolderLogBuilder().setFolder(folder).setLog(log).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogName ofBillingAccountLogName(String billingAccount, String log) { + return newBillingAccountLogBuilder().setBillingAccount(billingAccount).setLog(log).build(); + } + + public static String format(String project, String log) { + return newBuilder().setProject(project).setLog(log).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectLogName(String project, String log) { + return newBuilder().setProject(project).setLog(log).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationLogName(String organization, String log) { + return newOrganizationLogBuilder().setOrganization(organization).setLog(log).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderLogName(String folder, String log) { + return newFolderLogBuilder().setFolder(folder).setLog(log).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatBillingAccountLogName(String billingAccount, String log) { + return newBillingAccountLogBuilder() + .setBillingAccount(billingAccount) + .setLog(log) + .build() + .toString(); + } + + public static LogName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + if (PROJECT_LOG.matches(formattedString)) { + Map matchMap = PROJECT_LOG.match(formattedString); + return ofProjectLogName(matchMap.get("project"), matchMap.get("log")); + } else if (ORGANIZATION_LOG.matches(formattedString)) { + Map matchMap = ORGANIZATION_LOG.match(formattedString); + return ofOrganizationLogName(matchMap.get("organization"), matchMap.get("log")); + } else if (FOLDER_LOG.matches(formattedString)) { + Map matchMap = FOLDER_LOG.match(formattedString); + return ofFolderLogName(matchMap.get("folder"), matchMap.get("log")); + } else if (BILLING_ACCOUNT_LOG.matches(formattedString)) { + Map matchMap = BILLING_ACCOUNT_LOG.match(formattedString); + return ofBillingAccountLogName(matchMap.get("billing_account"), matchMap.get("log")); + } + throw new ValidationException("LogName.parse: formattedString not in valid format"); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LogName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOG.matches(formattedString) + || ORGANIZATION_LOG.matches(formattedString) + || FOLDER_LOG.matches(formattedString) + || BILLING_ACCOUNT_LOG.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } + if (!Objects.isNull(log)) { + fieldMapBuilder.put("log", log); + } + if (!Objects.isNull(organization)) { + fieldMapBuilder.put("organization", organization); + } + if (!Objects.isNull(folder)) { + fieldMapBuilder.put("folder", folder); + } + if (!Objects.isNull(billingAccount)) { + fieldMapBuilder.put("billing_account", billingAccount); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LogName that = ((LogName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.log, that.log) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder) + && Objects.equals(this.billingAccount, that.billingAccount); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(log); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(billingAccount); + return h; + } + + /** Builder for projects/{project}/logs/{log}. */ + public static class Builder { + private String project; + private String log; + + private Builder() {} + + public String getProject() { + return project; + } + + public String getLog() { + return log; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLog(String log) { + this.log = log; + return this; + } + + private Builder(LogName logName) { + Preconditions.checkArgument( + Objects.equals(logName.pathTemplate, PROJECT_LOG), + "toBuilder is only supported when LogName has the pattern of projects/{project}/logs/{log}"); + project = logName.project; + log = logName.log; + } + + public LogName build() { + return new LogName(this); + } + } + + /** Builder for organizations/{organization}/logs/{log}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationLogBuilder { + private String organization; + private String log; + + private OrganizationLogBuilder() {} + + public String getOrganization() { + return organization; + } + + public String getLog() { + return log; + } + + public OrganizationLogBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public OrganizationLogBuilder setLog(String log) { + this.log = log; + return this; + } + + public LogName build() { + return new LogName(this); + } + } + + /** Builder for folders/{folder}/logs/{log}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderLogBuilder { + private String folder; + private String log; + + private FolderLogBuilder() {} + + public String getFolder() { + return folder; + } + + public String getLog() { + return log; + } + + public FolderLogBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public FolderLogBuilder setLog(String log) { + this.log = log; + return this; + } + + public LogName build() { + return new LogName(this); + } + } + + /** Builder for billingAccounts/{billing_account}/logs/{log}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class BillingAccountLogBuilder { + private String billingAccount; + private String log; + + private BillingAccountLogBuilder() {} + + public String getBillingAccount() { + return billingAccount; + } + + public String getLog() { + return log; + } + + public BillingAccountLogBuilder setBillingAccount(String billingAccount) { + this.billingAccount = billingAccount; + return this; + } + + public BillingAccountLogBuilder setLog(String log) { + this.log = log; + return this; + } + + public LogName build() { + return new LogName(this); + } + } +} diff --git a/test/integration/goldens/logging/LogSinkName.java b/test/integration/goldens/logging/LogSinkName.java new file mode 100644 index 0000000000..b2211390dc --- /dev/null +++ b/test/integration/goldens/logging/LogSinkName.java @@ -0,0 +1,439 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LogSinkName implements ResourceName { + private static final PathTemplate PROJECT_SINK = + PathTemplate.createWithoutUrlEncoding("projects/{project}/sinks/{sink}"); + private static final PathTemplate ORGANIZATION_SINK = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}/sinks/{sink}"); + private static final PathTemplate FOLDER_SINK = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/sinks/{sink}"); + private static final PathTemplate BILLING_ACCOUNT_SINK = + PathTemplate.createWithoutUrlEncoding("billingAccounts/{billing_account}/sinks/{sink}"); + private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; + private final String project; + private final String sink; + private final String organization; + private final String folder; + private final String billingAccount; + + private LogSinkName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + sink = Preconditions.checkNotNull(builder.getSink()); + organization = null; + folder = null; + billingAccount = null; + pathTemplate = PROJECT_SINK; + } + + private LogSinkName(OrganizationSinkBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + sink = Preconditions.checkNotNull(builder.getSink()); + project = null; + folder = null; + billingAccount = null; + pathTemplate = ORGANIZATION_SINK; + } + + private LogSinkName(FolderSinkBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + sink = Preconditions.checkNotNull(builder.getSink()); + project = null; + organization = null; + billingAccount = null; + pathTemplate = FOLDER_SINK; + } + + private LogSinkName(BillingAccountSinkBuilder builder) { + billingAccount = Preconditions.checkNotNull(builder.getBillingAccount()); + sink = Preconditions.checkNotNull(builder.getSink()); + project = null; + organization = null; + folder = null; + pathTemplate = BILLING_ACCOUNT_SINK; + } + + public String getProject() { + return project; + } + + public String getSink() { + return sink; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; + } + + public String getBillingAccount() { + return billingAccount; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectSinkBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationSinkBuilder newOrganizationSinkBuilder() { + return new OrganizationSinkBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderSinkBuilder newFolderSinkBuilder() { + return new FolderSinkBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static BillingAccountSinkBuilder newBillingAccountSinkBuilder() { + return new BillingAccountSinkBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LogSinkName of(String project, String sink) { + return newBuilder().setProject(project).setSink(sink).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogSinkName ofProjectSinkName(String project, String sink) { + return newBuilder().setProject(project).setSink(sink).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogSinkName ofOrganizationSinkName(String organization, String sink) { + return newOrganizationSinkBuilder().setOrganization(organization).setSink(sink).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogSinkName ofFolderSinkName(String folder, String sink) { + return newFolderSinkBuilder().setFolder(folder).setSink(sink).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static LogSinkName ofBillingAccountSinkName(String billingAccount, String sink) { + return newBillingAccountSinkBuilder().setBillingAccount(billingAccount).setSink(sink).build(); + } + + public static String format(String project, String sink) { + return newBuilder().setProject(project).setSink(sink).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectSinkName(String project, String sink) { + return newBuilder().setProject(project).setSink(sink).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationSinkName(String organization, String sink) { + return newOrganizationSinkBuilder() + .setOrganization(organization) + .setSink(sink) + .build() + .toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderSinkName(String folder, String sink) { + return newFolderSinkBuilder().setFolder(folder).setSink(sink).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatBillingAccountSinkName(String billingAccount, String sink) { + return newBillingAccountSinkBuilder() + .setBillingAccount(billingAccount) + .setSink(sink) + .build() + .toString(); + } + + public static LogSinkName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + if (PROJECT_SINK.matches(formattedString)) { + Map matchMap = PROJECT_SINK.match(formattedString); + return ofProjectSinkName(matchMap.get("project"), matchMap.get("sink")); + } else if (ORGANIZATION_SINK.matches(formattedString)) { + Map matchMap = ORGANIZATION_SINK.match(formattedString); + return ofOrganizationSinkName(matchMap.get("organization"), matchMap.get("sink")); + } else if (FOLDER_SINK.matches(formattedString)) { + Map matchMap = FOLDER_SINK.match(formattedString); + return ofFolderSinkName(matchMap.get("folder"), matchMap.get("sink")); + } else if (BILLING_ACCOUNT_SINK.matches(formattedString)) { + Map matchMap = BILLING_ACCOUNT_SINK.match(formattedString); + return ofBillingAccountSinkName(matchMap.get("billing_account"), matchMap.get("sink")); + } + throw new ValidationException("LogSinkName.parse: formattedString not in valid format"); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LogSinkName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_SINK.matches(formattedString) + || ORGANIZATION_SINK.matches(formattedString) + || FOLDER_SINK.matches(formattedString) + || BILLING_ACCOUNT_SINK.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } + if (!Objects.isNull(sink)) { + fieldMapBuilder.put("sink", sink); + } + if (!Objects.isNull(organization)) { + fieldMapBuilder.put("organization", organization); + } + if (!Objects.isNull(folder)) { + fieldMapBuilder.put("folder", folder); + } + if (!Objects.isNull(billingAccount)) { + fieldMapBuilder.put("billing_account", billingAccount); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LogSinkName that = ((LogSinkName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.sink, that.sink) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder) + && Objects.equals(this.billingAccount, that.billingAccount); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(sink); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(billingAccount); + return h; + } + + /** Builder for projects/{project}/sinks/{sink}. */ + public static class Builder { + private String project; + private String sink; + + private Builder() {} + + public String getProject() { + return project; + } + + public String getSink() { + return sink; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setSink(String sink) { + this.sink = sink; + return this; + } + + private Builder(LogSinkName logSinkName) { + Preconditions.checkArgument( + Objects.equals(logSinkName.pathTemplate, PROJECT_SINK), + "toBuilder is only supported when LogSinkName has the pattern of projects/{project}/sinks/{sink}"); + project = logSinkName.project; + sink = logSinkName.sink; + } + + public LogSinkName build() { + return new LogSinkName(this); + } + } + + /** Builder for organizations/{organization}/sinks/{sink}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationSinkBuilder { + private String organization; + private String sink; + + private OrganizationSinkBuilder() {} + + public String getOrganization() { + return organization; + } + + public String getSink() { + return sink; + } + + public OrganizationSinkBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public OrganizationSinkBuilder setSink(String sink) { + this.sink = sink; + return this; + } + + public LogSinkName build() { + return new LogSinkName(this); + } + } + + /** Builder for folders/{folder}/sinks/{sink}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderSinkBuilder { + private String folder; + private String sink; + + private FolderSinkBuilder() {} + + public String getFolder() { + return folder; + } + + public String getSink() { + return sink; + } + + public FolderSinkBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public FolderSinkBuilder setSink(String sink) { + this.sink = sink; + return this; + } + + public LogSinkName build() { + return new LogSinkName(this); + } + } + + /** Builder for billingAccounts/{billing_account}/sinks/{sink}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class BillingAccountSinkBuilder { + private String billingAccount; + private String sink; + + private BillingAccountSinkBuilder() {} + + public String getBillingAccount() { + return billingAccount; + } + + public String getSink() { + return sink; + } + + public BillingAccountSinkBuilder setBillingAccount(String billingAccount) { + this.billingAccount = billingAccount; + return this; + } + + public BillingAccountSinkBuilder setSink(String sink) { + this.sink = sink; + return this; + } + + public LogSinkName build() { + return new LogSinkName(this); + } + } +} diff --git a/test/integration/goldens/logging/LoggingServiceV2Client.java b/test/integration/goldens/logging/LoggingServiceV2Client.java new file mode 100644 index 0000000000..2bbf50ba65 --- /dev/null +++ b/test/integration/goldens/logging/LoggingServiceV2Client.java @@ -0,0 +1,888 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.MonitoredResource; +import com.google.api.MonitoredResourceDescriptor; +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.common.util.concurrent.MoreExecutors; +import com.google.logging.v2.stub.LoggingServiceV2Stub; +import com.google.logging.v2.stub.LoggingServiceV2StubSettings; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: Service for ingesting and querying logs. + * + *

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: + * + *

Note: close() needs to be called on the echoClient 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 LoggingServiceV2Settings to + * create(). For example: + * + *

To customize credentials: + * + *

To customize the endpoint: + */ +@BetaApi +@Generated("by gapic-generator") +public class LoggingServiceV2Client implements BackgroundResource { + private final LoggingServiceV2Settings settings; + private final LoggingServiceV2Stub stub; + + /** Constructs an instance of EchoClient with default settings. */ + public static final LoggingServiceV2Client create() throws IOException { + return create(LoggingServiceV2Settings.newBuilder().build()); + } + + /** + * Constructs an instance of EchoClient, 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 LoggingServiceV2Client create(LoggingServiceV2Settings settings) + throws IOException { + return new LoggingServiceV2Client(settings); + } + + /** + * Constructs an instance of EchoClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(LoggingServiceV2Settings). + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final LoggingServiceV2Client create(LoggingServiceV2Stub stub) { + return new LoggingServiceV2Client(stub); + } + + /** + * Constructs an instance of EchoClient, 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 LoggingServiceV2Client(LoggingServiceV2Settings settings) throws IOException { + this.settings = settings; + this.stub = ((LoggingServiceV2StubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected LoggingServiceV2Client(LoggingServiceV2Stub stub) { + this.settings = null; + this.stub = stub; + } + + public final LoggingServiceV2Settings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public LoggingServiceV2Stub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes all the log entries in a log. The log reappears if it receives new entries. Log entries + * written shortly before the delete operation might not be deleted. Entries received after the + * delete operation with a timestamp before the operation will be deleted. + * + *

Sample code: + * + * @param log_name Required. The resource name of the log to delete: + * "projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" + * `[LOG_ID]` must be URL-encoded. For example, `"projects/my-project-id/logs/syslog"`, + * `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. For more + * information about log names, see [LogEntry][google.logging.v2.LogEntry]. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Empty deleteLog(LogName logName) { + DeleteLogRequest request = + DeleteLogRequest.newBuilder() + .setLogName(Objects.isNull(logName) ? null : logName.toString()) + .build(); + return deleteLog(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes all the log entries in a log. The log reappears if it receives new entries. Log entries + * written shortly before the delete operation might not be deleted. Entries received after the + * delete operation with a timestamp before the operation will be deleted. + * + *

Sample code: + * + * @param log_name Required. The resource name of the log to delete: + * "projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" + * `[LOG_ID]` must be URL-encoded. For example, `"projects/my-project-id/logs/syslog"`, + * `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. For more + * information about log names, see [LogEntry][google.logging.v2.LogEntry]. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Empty deleteLog(String logName) { + DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(logName).build(); + return deleteLog(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes all the log entries in a log. The log reappears if it receives new entries. Log entries + * written shortly before the delete operation might not be deleted. Entries received after the + * delete operation with a timestamp before the operation will be deleted. + * + *

Sample code: + * + * @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 + */ + public final Empty deleteLog(DeleteLogRequest request) { + return deleteLogCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes all the log entries in a log. The log reappears if it receives new entries. Log entries + * written shortly before the delete operation might not be deleted. Entries received after the + * delete operation with a timestamp before the operation will be deleted. + * + *

Sample code: + */ + public final UnaryCallable deleteLogCallable() { + return stub.deleteLogCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Writes log entries to Logging. This API method is the only way to send log entries to Logging. + * This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging + * libraries configured to use Logging. A single request may contain log entries for a maximum of + * 1000 different resources (projects, organizations, billing accounts or folders) + * + *

Sample code: + * + * @param log_name Optional. A default log resource name that is assigned to all log entries in + * `entries` that do not specify a value for `log_name`: "projects/[PROJECT_ID]/logs/[LOG_ID]" + * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" + * `[LOG_ID]` must be URL-encoded. For example: "projects/my-project-id/logs/syslog" + * "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity" The + * permission `logging.logEntries.create` is needed on each project, organization, billing + * account, or folder that is receiving new log entries, whether the resource is specified in + * `logName` or in an individual log entry. + * @param resource Optional. A default monitored resource object that is assigned to all log + * entries in `entries` that do not specify a value for `resource`. Example: { "type": + * "gce_instance", "labels": { "zone": "us-central1-a", "instance_id": "00000000000000000000" + * }} See [LogEntry][google.logging.v2.LogEntry]. + * @param labels Optional. Default labels that are added to the `labels` field of all log entries + * in `entries`. If a log entry already has a label with the same key as a label in this + * parameter, then the log entry's label is not changed. See + * [LogEntry][google.logging.v2.LogEntry]. + * @param entries Required. The log entries to send to Logging. The order of log entries in this + * list does not matter. Values supplied in this method's `log_name`, `resource`, and `labels` + * fields are copied into those log entries in this list that do not include values for their + * corresponding fields. For more information, see the [LogEntry][google.logging.v2.LogEntry] + * type. If the `timestamp` or `insert_id` fields are missing in log entries, then this method + * supplies the current time or a unique identifier, respectively. The supplied values are + * chosen so that, among the log entries that did not supply their own values, the entries + * earlier in the list will sort before the entries later in the list. See the `entries.list` + * method. Log entries with timestamps that are more than the [logs retention + * period](https://cloud.google.com/logging/quota-policy) in the past or more than 24 hours in + * the future will not be available when calling `entries.list`. However, those log entries + * can still be [exported with + * LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). To improve + * throughput and to avoid exceeding the [quota + * limit](https://cloud.google.com/logging/quota-policy) for calls to `entries.write`, you + * should try to include several log entries in this list, rather than calling this method for + * each individual log entry. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final WriteLogEntriesResponse writeLogEntries( + LogName logName, + MonitoredResource resource, + Map labels, + List entries) { + WriteLogEntriesRequest request = + WriteLogEntriesRequest.newBuilder() + .setLogName(Objects.isNull(logName) ? null : logName.toString()) + .setResource(resource) + .putAllLabels(labels) + .addAllEntries(entries) + .build(); + return writeLogEntries(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Writes log entries to Logging. This API method is the only way to send log entries to Logging. + * This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging + * libraries configured to use Logging. A single request may contain log entries for a maximum of + * 1000 different resources (projects, organizations, billing accounts or folders) + * + *

Sample code: + * + * @param log_name Optional. A default log resource name that is assigned to all log entries in + * `entries` that do not specify a value for `log_name`: "projects/[PROJECT_ID]/logs/[LOG_ID]" + * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" + * `[LOG_ID]` must be URL-encoded. For example: "projects/my-project-id/logs/syslog" + * "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity" The + * permission `logging.logEntries.create` is needed on each project, organization, billing + * account, or folder that is receiving new log entries, whether the resource is specified in + * `logName` or in an individual log entry. + * @param resource Optional. A default monitored resource object that is assigned to all log + * entries in `entries` that do not specify a value for `resource`. Example: { "type": + * "gce_instance", "labels": { "zone": "us-central1-a", "instance_id": "00000000000000000000" + * }} See [LogEntry][google.logging.v2.LogEntry]. + * @param labels Optional. Default labels that are added to the `labels` field of all log entries + * in `entries`. If a log entry already has a label with the same key as a label in this + * parameter, then the log entry's label is not changed. See + * [LogEntry][google.logging.v2.LogEntry]. + * @param entries Required. The log entries to send to Logging. The order of log entries in this + * list does not matter. Values supplied in this method's `log_name`, `resource`, and `labels` + * fields are copied into those log entries in this list that do not include values for their + * corresponding fields. For more information, see the [LogEntry][google.logging.v2.LogEntry] + * type. If the `timestamp` or `insert_id` fields are missing in log entries, then this method + * supplies the current time or a unique identifier, respectively. The supplied values are + * chosen so that, among the log entries that did not supply their own values, the entries + * earlier in the list will sort before the entries later in the list. See the `entries.list` + * method. Log entries with timestamps that are more than the [logs retention + * period](https://cloud.google.com/logging/quota-policy) in the past or more than 24 hours in + * the future will not be available when calling `entries.list`. However, those log entries + * can still be [exported with + * LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). To improve + * throughput and to avoid exceeding the [quota + * limit](https://cloud.google.com/logging/quota-policy) for calls to `entries.write`, you + * should try to include several log entries in this list, rather than calling this method for + * each individual log entry. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final WriteLogEntriesResponse writeLogEntries( + String logName, + MonitoredResource resource, + Map labels, + List entries) { + WriteLogEntriesRequest request = + WriteLogEntriesRequest.newBuilder() + .setLogName(logName) + .setResource(resource) + .putAllLabels(labels) + .addAllEntries(entries) + .build(); + return writeLogEntries(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Writes log entries to Logging. This API method is the only way to send log entries to Logging. + * This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging + * libraries configured to use Logging. A single request may contain log entries for a maximum of + * 1000 different resources (projects, organizations, billing accounts or folders) + * + *

Sample code: + * + * @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 + */ + public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest request) { + return writeLogEntriesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Writes log entries to Logging. This API method is the only way to send log entries to Logging. + * This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging + * libraries configured to use Logging. A single request may contain log entries for a maximum of + * 1000 different resources (projects, organizations, billing accounts or folders) + * + *

Sample code: + */ + public final UnaryCallable + writeLogEntriesCallable() { + return stub.writeLogEntriesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists log entries. Use this method to retrieve log entries that originated from a + * project/folder/organization/billing account. For ways to export log entries, see [Exporting + * Logs](https://cloud.google.com/logging/docs/export). + * + *

Sample code: + * + * @param resource_names Required. Names of one or more parent resources from which to retrieve + * log entries: "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" Projects listed in the + * `project_ids` field are added to this list. + * @param filter Optional. A filter that chooses which log entries to return. See [Advanced Logs + * Queries](https://cloud.google.com/logging/docs/view/advanced-queries). Only log entries + * that match the filter are returned. An empty filter matches all log entries in the + * resources listed in `resource_names`. Referencing a parent resource that is not listed in + * `resource_names` will cause the filter to return no results. The maximum length of the + * filter is 20000 characters. + * @param order_by Optional. How the results should be sorted. Presently, the only permitted + * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first option returns + * entries in order of increasing values of `LogEntry.timestamp` (oldest first), and the + * second option returns entries in order of decreasing timestamps (newest first). Entries + * with equal timestamps are returned in order of their `insert_id` values. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLogEntriesPagedResponse listLogEntries( + List resourceNames, String filter, String orderBy) { + ListLogEntriesRequest request = + ListLogEntriesRequest.newBuilder() + .addAllResourceNames(resourceNames) + .setFilter(filter) + .setOrderBy(orderBy) + .build(); + return listLogEntries(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists log entries. Use this method to retrieve log entries that originated from a + * project/folder/organization/billing account. For ways to export log entries, see [Exporting + * Logs](https://cloud.google.com/logging/docs/export). + * + *

Sample code: + * + * @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 + */ + public final ListLogEntriesPagedResponse listLogEntries(ListLogEntriesRequest request) { + return listLogEntriesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists log entries. Use this method to retrieve log entries that originated from a + * project/folder/organization/billing account. For ways to export log entries, see [Exporting + * Logs](https://cloud.google.com/logging/docs/export). + * + *

Sample code: + */ + public final UnaryCallable + listLogEntriesPagedCallable() { + return stub.listLogEntriesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists log entries. Use this method to retrieve log entries that originated from a + * project/folder/organization/billing account. For ways to export log entries, see [Exporting + * Logs](https://cloud.google.com/logging/docs/export). + * + *

Sample code: + */ + public final UnaryCallable + listLogEntriesCallable() { + return stub.listLogEntriesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the descriptors for monitored resource types used by Logging. + * + *

Sample code: + * + * @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 + */ + public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResourceDescriptors( + ListMonitoredResourceDescriptorsRequest request) { + return listMonitoredResourceDescriptorsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the descriptors for monitored resource types used by Logging. + * + *

Sample code: + */ + public final UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsPagedCallable() { + return stub.listMonitoredResourceDescriptorsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the descriptors for monitored resource types used by Logging. + * + *

Sample code: + */ + public final UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> + listMonitoredResourceDescriptorsCallable() { + return stub.listMonitoredResourceDescriptorsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have + * entries are listed. + * + *

Sample code: + * + * @param parent Required. The resource name that owns the logs: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLogsPagedResponse listLogs(BillingAccountName parent) { + ListLogsRequest request = + ListLogsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listLogs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have + * entries are listed. + * + *

Sample code: + * + * @param parent Required. The resource name that owns the logs: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLogsPagedResponse listLogs(FolderName parent) { + ListLogsRequest request = + ListLogsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listLogs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have + * entries are listed. + * + *

Sample code: + * + * @param parent Required. The resource name that owns the logs: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLogsPagedResponse listLogs(OrganizationName parent) { + ListLogsRequest request = + ListLogsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listLogs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have + * entries are listed. + * + *

Sample code: + * + * @param parent Required. The resource name that owns the logs: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLogsPagedResponse listLogs(ProjectName parent) { + ListLogsRequest request = + ListLogsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listLogs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have + * entries are listed. + * + *

Sample code: + * + * @param parent Required. The resource name that owns the logs: "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLogsPagedResponse listLogs(String parent) { + ListLogsRequest request = ListLogsRequest.newBuilder().setParent(parent).build(); + return listLogs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have + * entries are listed. + * + *

Sample code: + * + * @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 + */ + public final ListLogsPagedResponse listLogs(ListLogsRequest request) { + return listLogsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have + * entries are listed. + * + *

Sample code: + */ + public final UnaryCallable listLogsPagedCallable() { + return stub.listLogsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have + * entries are listed. + * + *

Sample code: + */ + public final UnaryCallable listLogsCallable() { + return stub.listLogsCallable(); + } + + @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 ListLogEntriesPagedResponse + extends AbstractPagedListResponse< + ListLogEntriesRequest, + ListLogEntriesResponse, + LogEntry, + ListLogEntriesPage, + ListLogEntriesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListLogEntriesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListLogEntriesPagedResponse apply(ListLogEntriesPage input) { + return new ListLogEntriesPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListLogEntriesPagedResponse(ListLogEntriesPage page) { + super(page, ListLogEntriesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListLogEntriesPage + extends AbstractPage< + ListLogEntriesRequest, ListLogEntriesResponse, LogEntry, ListLogEntriesPage> { + + private ListLogEntriesPage( + PageContext context, + ListLogEntriesResponse response) { + super(context, response); + } + + private static ListLogEntriesPage createEmptyPage() { + return new ListLogEntriesPage(null, null); + } + + @Override + protected ListLogEntriesPage createPage( + PageContext context, + ListLogEntriesResponse response) { + return new ListLogEntriesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListLogEntriesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListLogEntriesRequest, + ListLogEntriesResponse, + LogEntry, + ListLogEntriesPage, + ListLogEntriesFixedSizeCollection> { + + private ListLogEntriesFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListLogEntriesFixedSizeCollection createEmptyCollection() { + return new ListLogEntriesFixedSizeCollection(null, 0); + } + + @Override + protected ListLogEntriesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListLogEntriesFixedSizeCollection(pages, collectionSize); + } + } + + public static class ListMonitoredResourceDescriptorsPagedResponse + extends AbstractPagedListResponse< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor, + ListMonitoredResourceDescriptorsPage, + ListMonitoredResourceDescriptorsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> + context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListMonitoredResourceDescriptorsPage.createEmptyPage() + .createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction< + ListMonitoredResourceDescriptorsPage, + ListMonitoredResourceDescriptorsPagedResponse>() { + @Override + public ListMonitoredResourceDescriptorsPagedResponse apply( + ListMonitoredResourceDescriptorsPage input) { + return new ListMonitoredResourceDescriptorsPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListMonitoredResourceDescriptorsPagedResponse( + ListMonitoredResourceDescriptorsPage page) { + super(page, ListMonitoredResourceDescriptorsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListMonitoredResourceDescriptorsPage + extends AbstractPage< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor, + ListMonitoredResourceDescriptorsPage> { + + private ListMonitoredResourceDescriptorsPage( + PageContext< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> + context, + ListMonitoredResourceDescriptorsResponse response) { + super(context, response); + } + + private static ListMonitoredResourceDescriptorsPage createEmptyPage() { + return new ListMonitoredResourceDescriptorsPage(null, null); + } + + @Override + protected ListMonitoredResourceDescriptorsPage createPage( + PageContext< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> + context, + ListMonitoredResourceDescriptorsResponse response) { + return new ListMonitoredResourceDescriptorsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> + context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListMonitoredResourceDescriptorsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor, + ListMonitoredResourceDescriptorsPage, + ListMonitoredResourceDescriptorsFixedSizeCollection> { + + private ListMonitoredResourceDescriptorsFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListMonitoredResourceDescriptorsFixedSizeCollection createEmptyCollection() { + return new ListMonitoredResourceDescriptorsFixedSizeCollection(null, 0); + } + + @Override + protected ListMonitoredResourceDescriptorsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListMonitoredResourceDescriptorsFixedSizeCollection(pages, collectionSize); + } + } + + public static class ListLogsPagedResponse + extends AbstractPagedListResponse< + ListLogsRequest, ListLogsResponse, String, ListLogsPage, ListLogsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListLogsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListLogsPagedResponse apply(ListLogsPage input) { + return new ListLogsPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListLogsPagedResponse(ListLogsPage page) { + super(page, ListLogsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListLogsPage + extends AbstractPage { + + private ListLogsPage( + PageContext context, ListLogsResponse response) { + super(context, response); + } + + private static ListLogsPage createEmptyPage() { + return new ListLogsPage(null, null); + } + + @Override + protected ListLogsPage createPage( + PageContext context, ListLogsResponse response) { + return new ListLogsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListLogsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListLogsRequest, ListLogsResponse, String, ListLogsPage, ListLogsFixedSizeCollection> { + + private ListLogsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListLogsFixedSizeCollection createEmptyCollection() { + return new ListLogsFixedSizeCollection(null, 0); + } + + @Override + protected ListLogsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListLogsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/test/integration/goldens/logging/LoggingServiceV2Settings.java b/test/integration/goldens/logging/LoggingServiceV2Settings.java new file mode 100644 index 0000000000..83dc356803 --- /dev/null +++ b/test/integration/goldens/logging/LoggingServiceV2Settings.java @@ -0,0 +1,231 @@ +/* + * Copyright 2020 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.logging.v2; + +import static com.google.logging.v2.LoggingServiceV2Client.ListLogEntriesPagedResponse; +import static com.google.logging.v2.LoggingServiceV2Client.ListLogsPagedResponse; +import static com.google.logging.v2.LoggingServiceV2Client.ListMonitoredResourceDescriptorsPagedResponse; + +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.grpc.InstantiatingGrpcChannelProvider; +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.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.logging.v2.stub.LoggingServiceV2StubSettings; +import com.google.protobuf.Empty; +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 LoggingServiceV2Client}. + * + *

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

    + *
  • The default service address (logging.googleapis.com) 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 deleteLog to 30 seconds: + */ +@Generated("by gapic-generator-java") +public class LoggingServiceV2Settings extends ClientSettings { + + /** Returns the object with the settings used for calls to deleteLog. */ + public UnaryCallSettings deleteLogSettings() { + return ((LoggingServiceV2StubSettings) getStubSettings()).deleteLogSettings(); + } + + /** Returns the object with the settings used for calls to writeLogEntries. */ + public UnaryCallSettings + writeLogEntriesSettings() { + return ((LoggingServiceV2StubSettings) getStubSettings()).writeLogEntriesSettings(); + } + + /** Returns the object with the settings used for calls to listLogEntries. */ + public PagedCallSettings< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> + listLogEntriesSettings() { + return ((LoggingServiceV2StubSettings) getStubSettings()).listLogEntriesSettings(); + } + + /** Returns the object with the settings used for calls to listMonitoredResourceDescriptors. */ + public PagedCallSettings< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsSettings() { + return ((LoggingServiceV2StubSettings) getStubSettings()) + .listMonitoredResourceDescriptorsSettings(); + } + + /** Returns the object with the settings used for calls to listLogs. */ + public PagedCallSettings + listLogsSettings() { + return ((LoggingServiceV2StubSettings) getStubSettings()).listLogsSettings(); + } + + public static final LoggingServiceV2Settings create(LoggingServiceV2StubSettings stub) + throws IOException { + return new LoggingServiceV2Settings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return LoggingServiceV2StubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return LoggingServiceV2StubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return LoggingServiceV2StubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return LoggingServiceV2StubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return LoggingServiceV2StubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return LoggingServiceV2StubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return LoggingServiceV2StubSettings.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 LoggingServiceV2Settings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for LoggingServiceV2Settings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(LoggingServiceV2StubSettings.newBuilder(clientContext)); + } + + protected Builder(LoggingServiceV2Settings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(LoggingServiceV2StubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(LoggingServiceV2StubSettings.newBuilder()); + } + + public LoggingServiceV2StubSettings.Builder getStubSettingsBuilder() { + return ((LoggingServiceV2StubSettings.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 deleteLog. */ + public UnaryCallSettings.Builder deleteLogSettings() { + return getStubSettingsBuilder().deleteLogSettings(); + } + + /** Returns the builder for the settings used for calls to writeLogEntries. */ + public UnaryCallSettings.Builder + writeLogEntriesSettings() { + return getStubSettingsBuilder().writeLogEntriesSettings(); + } + + /** Returns the builder for the settings used for calls to listLogEntries. */ + public PagedCallSettings.Builder< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> + listLogEntriesSettings() { + return getStubSettingsBuilder().listLogEntriesSettings(); + } + + /** Returns the builder for the settings used for calls to listMonitoredResourceDescriptors. */ + public PagedCallSettings.Builder< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsSettings() { + return getStubSettingsBuilder().listMonitoredResourceDescriptorsSettings(); + } + + /** Returns the builder for the settings used for calls to listLogs. */ + public PagedCallSettings.Builder + listLogsSettings() { + return getStubSettingsBuilder().listLogsSettings(); + } + + @Override + public LoggingServiceV2Settings build() throws IOException { + return new LoggingServiceV2Settings(this); + } + } +} diff --git a/test/integration/goldens/logging/LoggingServiceV2Stub.java b/test/integration/goldens/logging/LoggingServiceV2Stub.java new file mode 100644 index 0000000000..5eef9cae5e --- /dev/null +++ b/test/integration/goldens/logging/LoggingServiceV2Stub.java @@ -0,0 +1,87 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.LoggingServiceV2Client.ListLogEntriesPagedResponse; +import static com.google.logging.v2.LoggingServiceV2Client.ListLogsPagedResponse; +import static com.google.logging.v2.LoggingServiceV2Client.ListMonitoredResourceDescriptorsPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.logging.v2.DeleteLogRequest; +import com.google.logging.v2.ListLogEntriesRequest; +import com.google.logging.v2.ListLogEntriesResponse; +import com.google.logging.v2.ListLogsRequest; +import com.google.logging.v2.ListLogsResponse; +import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest; +import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse; +import com.google.logging.v2.WriteLogEntriesRequest; +import com.google.logging.v2.WriteLogEntriesResponse; +import com.google.protobuf.Empty; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the LoggingServiceV2 service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +public abstract class LoggingServiceV2Stub implements BackgroundResource { + + public UnaryCallable deleteLogCallable() { + throw new UnsupportedOperationException("Not implemented: deleteLogCallable()"); + } + + public UnaryCallable writeLogEntriesCallable() { + throw new UnsupportedOperationException("Not implemented: writeLogEntriesCallable()"); + } + + public UnaryCallable + listLogEntriesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listLogEntriesPagedCallable()"); + } + + public UnaryCallable listLogEntriesCallable() { + throw new UnsupportedOperationException("Not implemented: listLogEntriesCallable()"); + } + + public UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsPagedCallable() { + throw new UnsupportedOperationException( + "Not implemented: listMonitoredResourceDescriptorsPagedCallable()"); + } + + public UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> + listMonitoredResourceDescriptorsCallable() { + throw new UnsupportedOperationException( + "Not implemented: listMonitoredResourceDescriptorsCallable()"); + } + + public UnaryCallable listLogsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listLogsPagedCallable()"); + } + + public UnaryCallable listLogsCallable() { + throw new UnsupportedOperationException("Not implemented: listLogsCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/test/integration/goldens/logging/LoggingServiceV2StubSettings.java b/test/integration/goldens/logging/LoggingServiceV2StubSettings.java new file mode 100644 index 0000000000..7e6456b3d4 --- /dev/null +++ b/test/integration/goldens/logging/LoggingServiceV2StubSettings.java @@ -0,0 +1,598 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.LoggingServiceV2Client.ListLogEntriesPagedResponse; +import static com.google.logging.v2.LoggingServiceV2Client.ListLogsPagedResponse; +import static com.google.logging.v2.LoggingServiceV2Client.ListMonitoredResourceDescriptorsPagedResponse; + +import com.google.api.MonitoredResourceDescriptor; +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.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +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.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.logging.v2.DeleteLogRequest; +import com.google.logging.v2.ListLogEntriesRequest; +import com.google.logging.v2.ListLogEntriesResponse; +import com.google.logging.v2.ListLogsRequest; +import com.google.logging.v2.ListLogsResponse; +import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest; +import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse; +import com.google.logging.v2.LogEntry; +import com.google.logging.v2.WriteLogEntriesRequest; +import com.google.logging.v2.WriteLogEntriesResponse; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link LoggingServiceV2Stub}. + * + *

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

    + *
  • The default service address (logging.googleapis.com) 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 deleteLog to 30 seconds: + */ +@BetaApi +@Generated("by gapic-generator-java") +public class LoggingServiceV2StubSettings 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/cloud-platform.read-only") + .add("https://www.googleapis.com/auth/logging.admin") + .add("https://www.googleapis.com/auth/logging.read") + .add("https://www.googleapis.com/auth/logging.write") + .build(); + + private final UnaryCallSettings deleteLogSettings; + private final UnaryCallSettings + writeLogEntriesSettings; + private final PagedCallSettings< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> + listLogEntriesSettings; + private final PagedCallSettings< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsSettings; + private final PagedCallSettings + listLogsSettings; + + private static final PagedListDescriptor + LIST_LOG_ENTRIES_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListLogEntriesRequest injectToken(ListLogEntriesRequest payload, String token) { + return ListLogEntriesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListLogEntriesRequest injectPageSize( + ListLogEntriesRequest payload, int pageSize) { + return ListLogEntriesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListLogEntriesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListLogEntriesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListLogEntriesResponse payload) { + return Objects.isNull(payload.getEntriesList()) + ? ImmutableList.of() + : payload.getEntriesList(); + } + }; + + private static final PagedListDescriptor< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> + LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC = + new PagedListDescriptor< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor>() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListMonitoredResourceDescriptorsRequest injectToken( + ListMonitoredResourceDescriptorsRequest payload, String token) { + return ListMonitoredResourceDescriptorsRequest.newBuilder(payload) + .setPageToken(token) + .build(); + } + + @Override + public ListMonitoredResourceDescriptorsRequest injectPageSize( + ListMonitoredResourceDescriptorsRequest payload, int pageSize) { + return ListMonitoredResourceDescriptorsRequest.newBuilder(payload) + .setPageSize(pageSize) + .build(); + } + + @Override + public Integer extractPageSize(ListMonitoredResourceDescriptorsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListMonitoredResourceDescriptorsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources( + ListMonitoredResourceDescriptorsResponse payload) { + return Objects.isNull(payload.getResourceDescriptorsList()) + ? ImmutableList.of() + : payload.getResourceDescriptorsList(); + } + }; + + private static final PagedListDescriptor + LIST_LOGS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListLogsRequest injectToken(ListLogsRequest payload, String token) { + return ListLogsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListLogsRequest injectPageSize(ListLogsRequest payload, int pageSize) { + return ListLogsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListLogsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListLogsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListLogsResponse payload) { + return Objects.isNull(payload.getLogNamesList()) + ? ImmutableList.of() + : payload.getLogNamesList(); + } + }; + + private static final PagedListResponseFactory< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> + LIST_LOG_ENTRIES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListLogEntriesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_LOG_ENTRIES_PAGE_STR_DESC, request, context); + return ListLogEntriesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse> + callable, + ListMonitoredResourceDescriptorsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> + pageContext = + PageContext.create( + callable, + LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC, + request, + context); + return ListMonitoredResourceDescriptorsPagedResponse.createAsync( + pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListLogsRequest, ListLogsResponse, ListLogsPagedResponse> + LIST_LOGS_PAGE_STR_FACT = + new PagedListResponseFactory() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListLogsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_LOGS_PAGE_STR_DESC, request, context); + return ListLogsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to deleteLog. */ + public UnaryCallSettings deleteLogSettings() { + return deleteLogSettings; + } + + /** Returns the object with the settings used for calls to writeLogEntries. */ + public UnaryCallSettings + writeLogEntriesSettings() { + return writeLogEntriesSettings; + } + + /** Returns the object with the settings used for calls to listLogEntries. */ + public PagedCallSettings< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> + listLogEntriesSettings() { + return listLogEntriesSettings; + } + + /** Returns the object with the settings used for calls to listMonitoredResourceDescriptors. */ + public PagedCallSettings< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsSettings() { + return listMonitoredResourceDescriptorsSettings; + } + + /** Returns the object with the settings used for calls to listLogs. */ + public PagedCallSettings + listLogsSettings() { + return listLogsSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public LoggingServiceV2Stub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcLoggingServiceV2Stub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", 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 "logging.googleapis.com: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 InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().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(LoggingServiceV2StubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** 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 LoggingServiceV2StubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + deleteLogSettings = settingsBuilder.deleteLogSettings().build(); + writeLogEntriesSettings = settingsBuilder.writeLogEntriesSettings().build(); + listLogEntriesSettings = settingsBuilder.listLogEntriesSettings().build(); + listMonitoredResourceDescriptorsSettings = + settingsBuilder.listMonitoredResourceDescriptorsSettings().build(); + listLogsSettings = settingsBuilder.listLogsSettings().build(); + } + + /** Builder for LoggingServiceV2StubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder deleteLogSettings; + private final UnaryCallSettings.Builder + writeLogEntriesSettings; + private final PagedCallSettings.Builder< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> + listLogEntriesSettings; + private final PagedCallSettings.Builder< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsSettings; + private final PagedCallSettings.Builder< + ListLogsRequest, ListLogsResponse, ListLogsPagedResponse> + listLogsSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_1_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, + StatusCode.Code.INTERNAL, + StatusCode.Code.UNAVAILABLE))); + 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(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_1_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + deleteLogSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + writeLogEntriesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listLogEntriesSettings = PagedCallSettings.newBuilder(LIST_LOG_ENTRIES_PAGE_STR_FACT); + listMonitoredResourceDescriptorsSettings = + PagedCallSettings.newBuilder(LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT); + listLogsSettings = PagedCallSettings.newBuilder(LIST_LOGS_PAGE_STR_FACT); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + deleteLogSettings, + writeLogEntriesSettings, + listLogEntriesSettings, + listMonitoredResourceDescriptorsSettings, + listLogsSettings); + initDefaults(this); + } + + protected Builder(LoggingServiceV2StubSettings settings) { + super(settings); + + deleteLogSettings = settings.deleteLogSettings.toBuilder(); + writeLogEntriesSettings = settings.writeLogEntriesSettings.toBuilder(); + listLogEntriesSettings = settings.listLogEntriesSettings.toBuilder(); + listMonitoredResourceDescriptorsSettings = + settings.listMonitoredResourceDescriptorsSettings.toBuilder(); + listLogsSettings = settings.listLogsSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + deleteLogSettings, + writeLogEntriesSettings, + listLogEntriesSettings, + listMonitoredResourceDescriptorsSettings, + listLogsSettings); + } + + 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 + .deleteLogSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .writeLogEntriesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .listLogEntriesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .listMonitoredResourceDescriptorsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .listLogsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + return builder; + } + + // 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 deleteLog. */ + public UnaryCallSettings.Builder deleteLogSettings() { + return deleteLogSettings; + } + + /** Returns the builder for the settings used for calls to writeLogEntries. */ + public UnaryCallSettings.Builder + writeLogEntriesSettings() { + return writeLogEntriesSettings; + } + + /** Returns the builder for the settings used for calls to listLogEntries. */ + public PagedCallSettings.Builder< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> + listLogEntriesSettings() { + return listLogEntriesSettings; + } + + /** Returns the builder for the settings used for calls to listMonitoredResourceDescriptors. */ + public PagedCallSettings.Builder< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsSettings() { + return listMonitoredResourceDescriptorsSettings; + } + + /** Returns the builder for the settings used for calls to listLogs. */ + public PagedCallSettings.Builder + listLogsSettings() { + return listLogsSettings; + } + + @Override + public LoggingServiceV2StubSettings build() throws IOException { + return new LoggingServiceV2StubSettings(this); + } + } +} diff --git a/test/integration/goldens/logging/MetricsServiceV2Client.java b/test/integration/goldens/logging/MetricsServiceV2Client.java new file mode 100644 index 0000000000..9341c256f0 --- /dev/null +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -0,0 +1,545 @@ +/* + * Copyright 2020 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.logging.v2; + +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.common.util.concurrent.MoreExecutors; +import com.google.logging.v2.stub.MetricsServiceV2Stub; +import com.google.logging.v2.stub.MetricsServiceV2StubSettings; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: Service for configuring logs-based metrics. + * + *

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: + * + *

Note: close() needs to be called on the echoClient 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 MetricsServiceV2Settings to + * create(). For example: + * + *

To customize credentials: + * + *

To customize the endpoint: + */ +@BetaApi +@Generated("by gapic-generator") +public class MetricsServiceV2Client implements BackgroundResource { + private final MetricsServiceV2Settings settings; + private final MetricsServiceV2Stub stub; + + /** Constructs an instance of EchoClient with default settings. */ + public static final MetricsServiceV2Client create() throws IOException { + return create(MetricsServiceV2Settings.newBuilder().build()); + } + + /** + * Constructs an instance of EchoClient, 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 MetricsServiceV2Client create(MetricsServiceV2Settings settings) + throws IOException { + return new MetricsServiceV2Client(settings); + } + + /** + * Constructs an instance of EchoClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(MetricsServiceV2Settings). + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final MetricsServiceV2Client create(MetricsServiceV2Stub stub) { + return new MetricsServiceV2Client(stub); + } + + /** + * Constructs an instance of EchoClient, 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 MetricsServiceV2Client(MetricsServiceV2Settings settings) throws IOException { + this.settings = settings; + this.stub = ((MetricsServiceV2StubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected MetricsServiceV2Client(MetricsServiceV2Stub stub) { + this.settings = null; + this.stub = stub; + } + + public final MetricsServiceV2Settings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public MetricsServiceV2Stub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists logs-based metrics. + * + *

Sample code: + * + * @param parent Required. The name of the project containing the metrics: "projects/[PROJECT_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLogMetricsPagedResponse listLogMetrics(ProjectName parent) { + ListLogMetricsRequest request = + ListLogMetricsRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .build(); + return listLogMetrics(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists logs-based metrics. + * + *

Sample code: + * + * @param parent Required. The name of the project containing the metrics: "projects/[PROJECT_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLogMetricsPagedResponse listLogMetrics(String parent) { + ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder().setParent(parent).build(); + return listLogMetrics(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists logs-based metrics. + * + *

Sample code: + * + * @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 + */ + public final ListLogMetricsPagedResponse listLogMetrics(ListLogMetricsRequest request) { + return listLogMetricsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists logs-based metrics. + * + *

Sample code: + */ + public final UnaryCallable + listLogMetricsPagedCallable() { + return stub.listLogMetricsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists logs-based metrics. + * + *

Sample code: + */ + public final UnaryCallable + listLogMetricsCallable() { + return stub.listLogMetricsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a logs-based metric. + * + *

Sample code: + * + * @param metric_name Required. The resource name of the desired metric: + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogMetric getLogMetric(LogMetricName metricName) { + GetLogMetricRequest request = + GetLogMetricRequest.newBuilder() + .setMetricName(Objects.isNull(metricName) ? null : metricName.toString()) + .build(); + return getLogMetric(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a logs-based metric. + * + *

Sample code: + * + * @param metric_name Required. The resource name of the desired metric: + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogMetric getLogMetric(String metricName) { + GetLogMetricRequest request = + GetLogMetricRequest.newBuilder().setMetricName(metricName).build(); + return getLogMetric(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a logs-based metric. + * + *

Sample code: + * + * @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 + */ + public final LogMetric getLogMetric(GetLogMetricRequest request) { + return getLogMetricCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a logs-based metric. + * + *

Sample code: + */ + public final UnaryCallable getLogMetricCallable() { + return stub.getLogMetricCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a logs-based metric. + * + *

Sample code: + * + * @param parent Required. The resource name of the project in which to create the metric: + * "projects/[PROJECT_ID]" The new metric must be provided in the request. + * @param metric Required. The new logs-based metric, which must not have an identifier that + * already exists. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogMetric createLogMetric(ProjectName parent, LogMetric metric) { + CreateLogMetricRequest request = + CreateLogMetricRequest.newBuilder() + .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setMetric(metric) + .build(); + return createLogMetric(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a logs-based metric. + * + *

Sample code: + * + * @param parent Required. The resource name of the project in which to create the metric: + * "projects/[PROJECT_ID]" The new metric must be provided in the request. + * @param metric Required. The new logs-based metric, which must not have an identifier that + * already exists. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogMetric createLogMetric(String parent, LogMetric metric) { + CreateLogMetricRequest request = + CreateLogMetricRequest.newBuilder().setParent(parent).setMetric(metric).build(); + return createLogMetric(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a logs-based metric. + * + *

Sample code: + * + * @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 + */ + public final LogMetric createLogMetric(CreateLogMetricRequest request) { + return createLogMetricCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a logs-based metric. + * + *

Sample code: + */ + public final UnaryCallable createLogMetricCallable() { + return stub.createLogMetricCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates or updates a logs-based metric. + * + *

Sample code: + * + * @param metric_name Required. The resource name of the metric to update: + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" The updated metric must be provided in the + * request and it's `name` field must be the same as `[METRIC_ID]` If the metric does not + * exist in `[PROJECT_ID]`, then a new metric is created. + * @param metric Required. The updated metric. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogMetric updateLogMetric(LogMetricName metricName, LogMetric metric) { + UpdateLogMetricRequest request = + UpdateLogMetricRequest.newBuilder() + .setMetricName(Objects.isNull(metricName) ? null : metricName.toString()) + .setMetric(metric) + .build(); + return updateLogMetric(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates or updates a logs-based metric. + * + *

Sample code: + * + * @param metric_name Required. The resource name of the metric to update: + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" The updated metric must be provided in the + * request and it's `name` field must be the same as `[METRIC_ID]` If the metric does not + * exist in `[PROJECT_ID]`, then a new metric is created. + * @param metric Required. The updated metric. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LogMetric updateLogMetric(String metricName, LogMetric metric) { + UpdateLogMetricRequest request = + UpdateLogMetricRequest.newBuilder().setMetricName(metricName).setMetric(metric).build(); + return updateLogMetric(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates or updates a logs-based metric. + * + *

Sample code: + * + * @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 + */ + public final LogMetric updateLogMetric(UpdateLogMetricRequest request) { + return updateLogMetricCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates or updates a logs-based metric. + * + *

Sample code: + */ + public final UnaryCallable updateLogMetricCallable() { + return stub.updateLogMetricCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a logs-based metric. + * + *

Sample code: + * + * @param metric_name Required. The resource name of the metric to delete: + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Empty deleteLogMetric(LogMetricName metricName) { + DeleteLogMetricRequest request = + DeleteLogMetricRequest.newBuilder() + .setMetricName(Objects.isNull(metricName) ? null : metricName.toString()) + .build(); + return deleteLogMetric(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a logs-based metric. + * + *

Sample code: + * + * @param metric_name Required. The resource name of the metric to delete: + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Empty deleteLogMetric(String metricName) { + DeleteLogMetricRequest request = + DeleteLogMetricRequest.newBuilder().setMetricName(metricName).build(); + return deleteLogMetric(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a logs-based metric. + * + *

Sample code: + * + * @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 + */ + public final Empty deleteLogMetric(DeleteLogMetricRequest request) { + return deleteLogMetricCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a logs-based metric. + * + *

Sample code: + */ + public final UnaryCallable deleteLogMetricCallable() { + return stub.deleteLogMetricCallable(); + } + + @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 ListLogMetricsPagedResponse + extends AbstractPagedListResponse< + ListLogMetricsRequest, + ListLogMetricsResponse, + LogMetric, + ListLogMetricsPage, + ListLogMetricsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListLogMetricsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListLogMetricsPagedResponse apply(ListLogMetricsPage input) { + return new ListLogMetricsPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListLogMetricsPagedResponse(ListLogMetricsPage page) { + super(page, ListLogMetricsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListLogMetricsPage + extends AbstractPage< + ListLogMetricsRequest, ListLogMetricsResponse, LogMetric, ListLogMetricsPage> { + + private ListLogMetricsPage( + PageContext context, + ListLogMetricsResponse response) { + super(context, response); + } + + private static ListLogMetricsPage createEmptyPage() { + return new ListLogMetricsPage(null, null); + } + + @Override + protected ListLogMetricsPage createPage( + PageContext context, + ListLogMetricsResponse response) { + return new ListLogMetricsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListLogMetricsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListLogMetricsRequest, + ListLogMetricsResponse, + LogMetric, + ListLogMetricsPage, + ListLogMetricsFixedSizeCollection> { + + private ListLogMetricsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListLogMetricsFixedSizeCollection createEmptyCollection() { + return new ListLogMetricsFixedSizeCollection(null, 0); + } + + @Override + protected ListLogMetricsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListLogMetricsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/test/integration/goldens/logging/MetricsServiceV2Settings.java b/test/integration/goldens/logging/MetricsServiceV2Settings.java new file mode 100644 index 0000000000..e9c0451fcb --- /dev/null +++ b/test/integration/goldens/logging/MetricsServiceV2Settings.java @@ -0,0 +1,216 @@ +/* + * Copyright 2020 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.logging.v2; + +import static com.google.logging.v2.MetricsServiceV2Client.ListLogMetricsPagedResponse; + +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.grpc.InstantiatingGrpcChannelProvider; +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.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.logging.v2.stub.MetricsServiceV2StubSettings; +import com.google.protobuf.Empty; +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 MetricsServiceV2Client}. + * + *

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

    + *
  • The default service address (logging.googleapis.com) 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 listLogMetrics to 30 seconds: + */ +@Generated("by gapic-generator-java") +public class MetricsServiceV2Settings extends ClientSettings { + + /** Returns the object with the settings used for calls to listLogMetrics. */ + public PagedCallSettings< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> + listLogMetricsSettings() { + return ((MetricsServiceV2StubSettings) getStubSettings()).listLogMetricsSettings(); + } + + /** Returns the object with the settings used for calls to getLogMetric. */ + public UnaryCallSettings getLogMetricSettings() { + return ((MetricsServiceV2StubSettings) getStubSettings()).getLogMetricSettings(); + } + + /** Returns the object with the settings used for calls to createLogMetric. */ + public UnaryCallSettings createLogMetricSettings() { + return ((MetricsServiceV2StubSettings) getStubSettings()).createLogMetricSettings(); + } + + /** Returns the object with the settings used for calls to updateLogMetric. */ + public UnaryCallSettings updateLogMetricSettings() { + return ((MetricsServiceV2StubSettings) getStubSettings()).updateLogMetricSettings(); + } + + /** Returns the object with the settings used for calls to deleteLogMetric. */ + public UnaryCallSettings deleteLogMetricSettings() { + return ((MetricsServiceV2StubSettings) getStubSettings()).deleteLogMetricSettings(); + } + + public static final MetricsServiceV2Settings create(MetricsServiceV2StubSettings stub) + throws IOException { + return new MetricsServiceV2Settings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return MetricsServiceV2StubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return MetricsServiceV2StubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return MetricsServiceV2StubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return MetricsServiceV2StubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return MetricsServiceV2StubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return MetricsServiceV2StubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return MetricsServiceV2StubSettings.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 MetricsServiceV2Settings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for MetricsServiceV2Settings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(MetricsServiceV2StubSettings.newBuilder(clientContext)); + } + + protected Builder(MetricsServiceV2Settings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(MetricsServiceV2StubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(MetricsServiceV2StubSettings.newBuilder()); + } + + public MetricsServiceV2StubSettings.Builder getStubSettingsBuilder() { + return ((MetricsServiceV2StubSettings.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 listLogMetrics. */ + public PagedCallSettings.Builder< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> + listLogMetricsSettings() { + return getStubSettingsBuilder().listLogMetricsSettings(); + } + + /** Returns the builder for the settings used for calls to getLogMetric. */ + public UnaryCallSettings.Builder getLogMetricSettings() { + return getStubSettingsBuilder().getLogMetricSettings(); + } + + /** Returns the builder for the settings used for calls to createLogMetric. */ + public UnaryCallSettings.Builder createLogMetricSettings() { + return getStubSettingsBuilder().createLogMetricSettings(); + } + + /** Returns the builder for the settings used for calls to updateLogMetric. */ + public UnaryCallSettings.Builder updateLogMetricSettings() { + return getStubSettingsBuilder().updateLogMetricSettings(); + } + + /** Returns the builder for the settings used for calls to deleteLogMetric. */ + public UnaryCallSettings.Builder deleteLogMetricSettings() { + return getStubSettingsBuilder().deleteLogMetricSettings(); + } + + @Override + public MetricsServiceV2Settings build() throws IOException { + return new MetricsServiceV2Settings(this); + } + } +} diff --git a/test/integration/goldens/logging/MetricsServiceV2Stub.java b/test/integration/goldens/logging/MetricsServiceV2Stub.java new file mode 100644 index 0000000000..c70df1c420 --- /dev/null +++ b/test/integration/goldens/logging/MetricsServiceV2Stub.java @@ -0,0 +1,69 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.MetricsServiceV2Client.ListLogMetricsPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.logging.v2.CreateLogMetricRequest; +import com.google.logging.v2.DeleteLogMetricRequest; +import com.google.logging.v2.GetLogMetricRequest; +import com.google.logging.v2.ListLogMetricsRequest; +import com.google.logging.v2.ListLogMetricsResponse; +import com.google.logging.v2.LogMetric; +import com.google.logging.v2.UpdateLogMetricRequest; +import com.google.protobuf.Empty; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the MetricsServiceV2 service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +public abstract class MetricsServiceV2Stub implements BackgroundResource { + + public UnaryCallable + listLogMetricsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listLogMetricsPagedCallable()"); + } + + public UnaryCallable listLogMetricsCallable() { + throw new UnsupportedOperationException("Not implemented: listLogMetricsCallable()"); + } + + public UnaryCallable getLogMetricCallable() { + throw new UnsupportedOperationException("Not implemented: getLogMetricCallable()"); + } + + public UnaryCallable createLogMetricCallable() { + throw new UnsupportedOperationException("Not implemented: createLogMetricCallable()"); + } + + public UnaryCallable updateLogMetricCallable() { + throw new UnsupportedOperationException("Not implemented: updateLogMetricCallable()"); + } + + public UnaryCallable deleteLogMetricCallable() { + throw new UnsupportedOperationException("Not implemented: deleteLogMetricCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/test/integration/goldens/logging/MetricsServiceV2StubSettings.java b/test/integration/goldens/logging/MetricsServiceV2StubSettings.java new file mode 100644 index 0000000000..2d0a8aedbc --- /dev/null +++ b/test/integration/goldens/logging/MetricsServiceV2StubSettings.java @@ -0,0 +1,442 @@ +/* + * Copyright 2020 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.logging.v2.stub; + +import static com.google.logging.v2.MetricsServiceV2Client.ListLogMetricsPagedResponse; + +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.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +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.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.logging.v2.CreateLogMetricRequest; +import com.google.logging.v2.DeleteLogMetricRequest; +import com.google.logging.v2.GetLogMetricRequest; +import com.google.logging.v2.ListLogMetricsRequest; +import com.google.logging.v2.ListLogMetricsResponse; +import com.google.logging.v2.LogMetric; +import com.google.logging.v2.UpdateLogMetricRequest; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link MetricsServiceV2Stub}. + * + *

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

    + *
  • The default service address (logging.googleapis.com) 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 listLogMetrics to 30 seconds: + */ +@BetaApi +@Generated("by gapic-generator-java") +public class MetricsServiceV2StubSettings 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/cloud-platform.read-only") + .add("https://www.googleapis.com/auth/logging.admin") + .add("https://www.googleapis.com/auth/logging.read") + .add("https://www.googleapis.com/auth/logging.write") + .build(); + + private final PagedCallSettings< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> + listLogMetricsSettings; + private final UnaryCallSettings getLogMetricSettings; + private final UnaryCallSettings createLogMetricSettings; + private final UnaryCallSettings updateLogMetricSettings; + private final UnaryCallSettings deleteLogMetricSettings; + + private static final PagedListDescriptor + LIST_LOG_METRICS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListLogMetricsRequest injectToken(ListLogMetricsRequest payload, String token) { + return ListLogMetricsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListLogMetricsRequest injectPageSize( + ListLogMetricsRequest payload, int pageSize) { + return ListLogMetricsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListLogMetricsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListLogMetricsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListLogMetricsResponse payload) { + return Objects.isNull(payload.getMetricsList()) + ? ImmutableList.of() + : payload.getMetricsList(); + } + }; + + private static final PagedListResponseFactory< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> + LIST_LOG_METRICS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListLogMetricsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_LOG_METRICS_PAGE_STR_DESC, request, context); + return ListLogMetricsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to listLogMetrics. */ + public PagedCallSettings< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> + listLogMetricsSettings() { + return listLogMetricsSettings; + } + + /** Returns the object with the settings used for calls to getLogMetric. */ + public UnaryCallSettings getLogMetricSettings() { + return getLogMetricSettings; + } + + /** Returns the object with the settings used for calls to createLogMetric. */ + public UnaryCallSettings createLogMetricSettings() { + return createLogMetricSettings; + } + + /** Returns the object with the settings used for calls to updateLogMetric. */ + public UnaryCallSettings updateLogMetricSettings() { + return updateLogMetricSettings; + } + + /** Returns the object with the settings used for calls to deleteLogMetric. */ + public UnaryCallSettings deleteLogMetricSettings() { + return deleteLogMetricSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public MetricsServiceV2Stub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcMetricsServiceV2Stub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", 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 "logging.googleapis.com: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 InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().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(MetricsServiceV2StubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** 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 MetricsServiceV2StubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listLogMetricsSettings = settingsBuilder.listLogMetricsSettings().build(); + getLogMetricSettings = settingsBuilder.getLogMetricSettings().build(); + createLogMetricSettings = settingsBuilder.createLogMetricSettings().build(); + updateLogMetricSettings = settingsBuilder.updateLogMetricSettings().build(); + deleteLogMetricSettings = settingsBuilder.deleteLogMetricSettings().build(); + } + + /** Builder for MetricsServiceV2StubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final PagedCallSettings.Builder< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> + listLogMetricsSettings; + private final UnaryCallSettings.Builder getLogMetricSettings; + private final UnaryCallSettings.Builder + createLogMetricSettings; + private final UnaryCallSettings.Builder + updateLogMetricSettings; + private final UnaryCallSettings.Builder deleteLogMetricSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_5_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, + StatusCode.Code.INTERNAL, + StatusCode.Code.UNAVAILABLE))); + definitions.put( + "no_retry_0_codes", 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(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_5_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("no_retry_0_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listLogMetricsSettings = PagedCallSettings.newBuilder(LIST_LOG_METRICS_PAGE_STR_FACT); + getLogMetricSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createLogMetricSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateLogMetricSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteLogMetricSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listLogMetricsSettings, + getLogMetricSettings, + createLogMetricSettings, + updateLogMetricSettings, + deleteLogMetricSettings); + initDefaults(this); + } + + protected Builder(MetricsServiceV2StubSettings settings) { + super(settings); + + listLogMetricsSettings = settings.listLogMetricsSettings.toBuilder(); + getLogMetricSettings = settings.getLogMetricSettings.toBuilder(); + createLogMetricSettings = settings.createLogMetricSettings.toBuilder(); + updateLogMetricSettings = settings.updateLogMetricSettings.toBuilder(); + deleteLogMetricSettings = settings.deleteLogMetricSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listLogMetricsSettings, + getLogMetricSettings, + createLogMetricSettings, + updateLogMetricSettings, + deleteLogMetricSettings); + } + + 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 + .listLogMetricsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); + + builder + .getLogMetricSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); + + builder + .createLogMetricSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + + builder + .updateLogMetricSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); + + builder + .deleteLogMetricSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); + + return builder; + } + + // 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 listLogMetrics. */ + public PagedCallSettings.Builder< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> + listLogMetricsSettings() { + return listLogMetricsSettings; + } + + /** Returns the builder for the settings used for calls to getLogMetric. */ + public UnaryCallSettings.Builder getLogMetricSettings() { + return getLogMetricSettings; + } + + /** Returns the builder for the settings used for calls to createLogMetric. */ + public UnaryCallSettings.Builder createLogMetricSettings() { + return createLogMetricSettings; + } + + /** Returns the builder for the settings used for calls to updateLogMetric. */ + public UnaryCallSettings.Builder updateLogMetricSettings() { + return updateLogMetricSettings; + } + + /** Returns the builder for the settings used for calls to deleteLogMetric. */ + public UnaryCallSettings.Builder deleteLogMetricSettings() { + return deleteLogMetricSettings; + } + + @Override + public MetricsServiceV2StubSettings build() throws IOException { + return new MetricsServiceV2StubSettings(this); + } + } +} diff --git a/test/integration/goldens/logging/OrganizationLocationName.java b/test/integration/goldens/logging/OrganizationLocationName.java new file mode 100644 index 0000000000..08dbc40fd5 --- /dev/null +++ b/test/integration/goldens/logging/OrganizationLocationName.java @@ -0,0 +1,186 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class OrganizationLocationName implements ResourceName { + private static final PathTemplate ORGANIZATION_LOCATION = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}/locations/{location}"); + private volatile Map fieldValuesMap; + private final String organization; + private final String location; + + private OrganizationLocationName(Builder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + + public String getOrganization() { + return organization; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static OrganizationLocationName of(String organization, String location) { + return newBuilder().setOrganization(organization).setLocation(location).build(); + } + + public static String format(String organization, String location) { + return newBuilder().setOrganization(organization).setLocation(location).build().toString(); + } + + public static OrganizationLocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + ORGANIZATION_LOCATION.validatedMatch( + formattedString, "OrganizationLocationName.parse: formattedString not in valid format"); + return of(matchMap.get("organization"), matchMap.get("location")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (OrganizationLocationName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return ORGANIZATION_LOCATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(organization)) { + fieldMapBuilder.put("organization", organization); + } + if (!Objects.isNull(location)) { + fieldMapBuilder.put("location", location); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return ORGANIZATION_LOCATION.instantiate("organization", organization); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + OrganizationLocationName that = ((OrganizationLocationName) o); + return Objects.equals(this.organization, that.organization) + && Objects.equals(this.location, that.location); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for organizations/{organization}/locations/{location}. */ + public static class Builder { + private String organization; + private String location; + + private Builder() {} + + public String getOrganization() { + return organization; + } + + public String getLocation() { + return location; + } + + public Builder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(OrganizationLocationName organizationLocationName) { + organization = organizationLocationName.organization; + location = organizationLocationName.location; + } + + public OrganizationLocationName build() { + return new OrganizationLocationName(this); + } + } +} diff --git a/test/integration/goldens/logging/OrganizationName.java b/test/integration/goldens/logging/OrganizationName.java new file mode 100644 index 0000000000..a8860f3e9c --- /dev/null +++ b/test/integration/goldens/logging/OrganizationName.java @@ -0,0 +1,163 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class OrganizationName implements ResourceName { + private static final PathTemplate ORGANIZATION = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}"); + private volatile Map fieldValuesMap; + private final String organization; + + private OrganizationName(Builder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + } + + public String getOrganization() { + return organization; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static OrganizationName of(String organization) { + return newBuilder().setOrganization(organization).build(); + } + + public static String format(String organization) { + return newBuilder().setOrganization(organization).build().toString(); + } + + public static OrganizationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + ORGANIZATION.validatedMatch( + formattedString, "OrganizationName.parse: formattedString not in valid format"); + return of(matchMap.get("organization")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (OrganizationName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return ORGANIZATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(organization)) { + fieldMapBuilder.put("organization", organization); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return ORGANIZATION.instantiate("organization", organization); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + OrganizationName that = ((OrganizationName) o); + return Objects.equals(this.organization, that.organization); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(organization); + return h; + } + + /** Builder for organizations/{organization}. */ + public static class Builder { + private String organization; + + private Builder() {} + + public String getOrganization() { + return organization; + } + + public Builder setOrganization(String organization) { + this.organization = organization; + return this; + } + + private Builder(OrganizationName organizationName) { + organization = organizationName.organization; + } + + public OrganizationName build() { + return new OrganizationName(this); + } + } +} diff --git a/test/integration/goldens/logging/ProjectName.java b/test/integration/goldens/logging/ProjectName.java new file mode 100644 index 0000000000..2003259874 --- /dev/null +++ b/test/integration/goldens/logging/ProjectName.java @@ -0,0 +1,163 @@ +/* + * Copyright 2020 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.logging.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class ProjectName implements ResourceName { + private static final PathTemplate PROJECT = + PathTemplate.createWithoutUrlEncoding("projects/{project}"); + private volatile Map fieldValuesMap; + private final String project; + + private ProjectName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + } + + public String getProject() { + return project; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static ProjectName of(String project) { + return newBuilder().setProject(project).build(); + } + + public static String format(String project) { + return newBuilder().setProject(project).build().toString(); + } + + public static ProjectName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT.validatedMatch( + formattedString, "ProjectName.parse: formattedString not in valid format"); + return of(matchMap.get("project")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (ProjectName value : values) { + if (Objects.isNull(value)) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (Objects.isNull(fieldValuesMap)) { + synchronized (this) { + if (Objects.isNull(fieldValuesMap)) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT.instantiate("project", project); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ProjectName that = ((ProjectName) o); + return Objects.equals(this.project, that.project); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + return h; + } + + /** Builder for projects/{project}. */ + public static class Builder { + private String project; + + private Builder() {} + + public String getProject() { + return project; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + private Builder(ProjectName projectName) { + project = projectName.project; + } + + public ProjectName build() { + return new ProjectName(this); + } + } +} diff --git a/test/integration/goldens/logging/package-info.java b/test/integration/goldens/logging/package-info.java new file mode 100644 index 0000000000..f42783ea3f --- /dev/null +++ b/test/integration/goldens/logging/package-info.java @@ -0,0 +1,43 @@ +/* + * Copyright 2020 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. + */ + +/** + * A client to Cloud Logging API + * + *

The interfaces provided are listed below, along with usage samples. + * + *

======================= LoggingServiceV2Client ======================= + * + *

Service Description: Service for ingesting and querying logs. + * + *

Sample for LoggingServiceV2Client: + * + *

======================= ConfigServiceV2Client ======================= + * + *

Service Description: Service for configuring sinks used to route log entries. + * + *

Sample for ConfigServiceV2Client: + * + *

======================= MetricsServiceV2Client ======================= + * + *

Service Description: Service for configuring logs-based metrics. + * + *

Sample for MetricsServiceV2Client: + */ +@Generated("by gapic-generator-java") +package com.google.logging.v2; + +import javax.annotation.Generated;