Class ResourceSettingsServiceClient (1.54.0)

GitHub RepositoryProduct Reference

Deprecated. This class is deprecated and will be removed in the next major version update.

Service Description: An interface to interact with resource settings and setting values throughout the resource hierarchy.

Services may surface a number of settings for users to control how their resources behave. Values of settings applied on a given Cloud resource are evaluated hierarchically and inherited by all descendants of that resource.

For all requests, returns a google.rpc.Status with google.rpc.Code.PERMISSION_DENIED if the IAM check fails or the parent resource is not in a Cloud Organization. For all requests, returns a google.rpc.Status with google.rpc.Code.INVALID_ARGUMENT if the request is malformed. (== deprecation_description Resource Settings is deprecated. As of November 7, 2023, no organizations will be onboarded for any of the enabled settings, and the service will be shut down on October 1, 2024. ==)

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   SettingName name =
       SettingName.ofOrganizationSettingNameName("[ORGANIZATION]", "[SETTING_NAME]");
   Setting response = resourceSettingsServiceClient.getSetting(name);
 }
 

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

Methods
Method Description Method Variants

ListSettings

Lists all the settings that are available on the Cloud resource parent.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listSettings(ListSettingsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listSettings(ResourceName parent)

  • listSettings(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listSettingsPagedCallable()

  • listSettingsCallable()

GetSetting

Gets a setting.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the setting does not exist.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSetting(GetSettingRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSetting(SettingName name)

  • getSetting(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSettingCallable()

UpdateSetting

Updates a setting.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the setting does not exist. Returns a google.rpc.Status with google.rpc.Code.FAILED_PRECONDITION if the setting is flagged as read only. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the setting value.

On success, the response will contain only name, local_value and etag. The metadata and effective_value cannot be updated through this API.

Note: the supplied setting will perform a full overwrite of the local_value field.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateSetting(UpdateSettingRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateSettingCallable()

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 ResourceSettingsServiceSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ResourceSettingsServiceSettings resourceSettingsServiceSettings =
     ResourceSettingsServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create(resourceSettingsServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ResourceSettingsServiceSettings resourceSettingsServiceSettings =
     ResourceSettingsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create(resourceSettingsServiceSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ResourceSettingsServiceSettings resourceSettingsServiceSettings =
     ResourceSettingsServiceSettings.newHttpJsonBuilder().build();
 ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create(resourceSettingsServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ResourceSettingsServiceClient

Static Methods

create() (deprecated)

public static final ResourceSettingsServiceClient create()

Constructs an instance of ResourceSettingsServiceClient with default settings.

Returns
Type Description
ResourceSettingsServiceClient
Exceptions
Type Description
IOException

create(ResourceSettingsServiceSettings settings) (deprecated)

public static final ResourceSettingsServiceClient create(ResourceSettingsServiceSettings settings)

Constructs an instance of ResourceSettingsServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings ResourceSettingsServiceSettings
Returns
Type Description
ResourceSettingsServiceClient
Exceptions
Type Description
IOException

create(ResourceSettingsServiceStub stub) (deprecated)

public static final ResourceSettingsServiceClient create(ResourceSettingsServiceStub stub)

Constructs an instance of ResourceSettingsServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ResourceSettingsServiceSettings).

Parameter
Name Description
stub ResourceSettingsServiceStub
Returns
Type Description
ResourceSettingsServiceClient

Constructors

ResourceSettingsServiceClient(ResourceSettingsServiceSettings settings) (deprecated)

protected ResourceSettingsServiceClient(ResourceSettingsServiceSettings settings)

Constructs an instance of ResourceSettingsServiceClient, 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.

Parameter
Name Description
settings ResourceSettingsServiceSettings

ResourceSettingsServiceClient(ResourceSettingsServiceStub stub) (deprecated)

protected ResourceSettingsServiceClient(ResourceSettingsServiceStub stub)
Parameter
Name Description
stub ResourceSettingsServiceStub

Methods

awaitTermination(long duration, TimeUnit unit) (deprecated)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close() (deprecated)

public final void close()

getSetting(GetSettingRequest request) (deprecated)

public final Setting getSetting(GetSettingRequest request)

Gets a setting.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the setting does not exist.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   GetSettingRequest request =
       GetSettingRequest.newBuilder()
           .setName(
               SettingName.ofOrganizationSettingNameName("[ORGANIZATION]", "[SETTING_NAME]")
                   .toString())
           .setView(SettingView.forNumber(0))
           .build();
   Setting response = resourceSettingsServiceClient.getSetting(request);
 }
 
Parameter
Name Description
request GetSettingRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Setting

getSetting(SettingName name) (deprecated)

public final Setting getSetting(SettingName name)

Gets a setting.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the setting does not exist.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   SettingName name =
       SettingName.ofOrganizationSettingNameName("[ORGANIZATION]", "[SETTING_NAME]");
   Setting response = resourceSettingsServiceClient.getSetting(name);
 }
 
Parameter
Name Description
name SettingName

Required. The name of the setting to get. See Setting for naming requirements.

Returns
Type Description
Setting

getSetting(String name) (deprecated)

public final Setting getSetting(String name)

Gets a setting.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the setting does not exist.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   String name =
       SettingName.ofProjectNumberSettingNameName("[PROJECT_NUMBER]", "[SETTING_NAME]")
           .toString();
   Setting response = resourceSettingsServiceClient.getSetting(name);
 }
 
Parameter
Name Description
name String

Required. The name of the setting to get. See Setting for naming requirements.

Returns
Type Description
Setting

getSettingCallable() (deprecated)

public final UnaryCallable<GetSettingRequest,Setting> getSettingCallable()

Gets a setting.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the setting does not exist.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   GetSettingRequest request =
       GetSettingRequest.newBuilder()
           .setName(
               SettingName.ofOrganizationSettingNameName("[ORGANIZATION]", "[SETTING_NAME]")
                   .toString())
           .setView(SettingView.forNumber(0))
           .build();
   ApiFuture<Setting> future =
       resourceSettingsServiceClient.getSettingCallable().futureCall(request);
   // Do something.
   Setting response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetSettingRequest,Setting>

getSettings() (deprecated)

public final ResourceSettingsServiceSettings getSettings()
Returns
Type Description
ResourceSettingsServiceSettings

getStub() (deprecated)

public ResourceSettingsServiceStub getStub()
Returns
Type Description
ResourceSettingsServiceStub

isShutdown() (deprecated)

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated() (deprecated)

public boolean isTerminated()
Returns
Type Description
boolean

listSettings(ResourceName parent) (deprecated)

public final ResourceSettingsServiceClient.ListSettingsPagedResponse listSettings(ResourceName parent)

Lists all the settings that are available on the Cloud resource parent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   ResourceName parent =
       new ResourceName() {
         {@literal @}Override
         public Map<String, String> getFieldValuesMap() {
           Map<String, String> fieldValuesMap = new HashMap<>();
           fieldValuesMap.put("parent", "organizations/organization-8287");
           return fieldValuesMap;
         }

         {@literal @}Override
         public String getFieldValue(String fieldName) {
           return getFieldValuesMap().get(fieldName);
         }

         {@literal @}Override
         public String toString() {
           return "organizations/organization-8287";
         }
       };
   for (Setting element : resourceSettingsServiceClient.listSettings(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent com.google.api.resourcenames.ResourceName

Required. The Cloud resource that parents the setting. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}

Returns
Type Description
ResourceSettingsServiceClient.ListSettingsPagedResponse

listSettings(ListSettingsRequest request) (deprecated)

public final ResourceSettingsServiceClient.ListSettingsPagedResponse listSettings(ListSettingsRequest request)

Lists all the settings that are available on the Cloud resource parent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   ListSettingsRequest request =
       ListSettingsRequest.newBuilder()
           .setParent("ListSettingsRequest-286838706".toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setView(SettingView.forNumber(0))
           .build();
   for (Setting element : resourceSettingsServiceClient.listSettings(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListSettingsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ResourceSettingsServiceClient.ListSettingsPagedResponse

listSettings(String parent) (deprecated)

public final ResourceSettingsServiceClient.ListSettingsPagedResponse listSettings(String parent)

Lists all the settings that are available on the Cloud resource parent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   String parent =
       SettingName.ofProjectNumberSettingNameName("[PROJECT_NUMBER]", "[SETTING_NAME]")
           .toString();
   for (Setting element : resourceSettingsServiceClient.listSettings(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The Cloud resource that parents the setting. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}

Returns
Type Description
ResourceSettingsServiceClient.ListSettingsPagedResponse

listSettingsCallable() (deprecated)

public final UnaryCallable<ListSettingsRequest,ListSettingsResponse> listSettingsCallable()

Lists all the settings that are available on the Cloud resource parent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   ListSettingsRequest request =
       ListSettingsRequest.newBuilder()
           .setParent("ListSettingsRequest-286838706".toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setView(SettingView.forNumber(0))
           .build();
   while (true) {
     ListSettingsResponse response =
         resourceSettingsServiceClient.listSettingsCallable().call(request);
     for (Setting element : response.getSettingsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListSettingsRequest,ListSettingsResponse>

listSettingsPagedCallable() (deprecated)

public final UnaryCallable<ListSettingsRequest,ResourceSettingsServiceClient.ListSettingsPagedResponse> listSettingsPagedCallable()

Lists all the settings that are available on the Cloud resource parent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   ListSettingsRequest request =
       ListSettingsRequest.newBuilder()
           .setParent("ListSettingsRequest-286838706".toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setView(SettingView.forNumber(0))
           .build();
   ApiFuture<Setting> future =
       resourceSettingsServiceClient.listSettingsPagedCallable().futureCall(request);
   // Do something.
   for (Setting element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListSettingsRequest,ListSettingsPagedResponse>

shutdown() (deprecated)

public void shutdown()

shutdownNow() (deprecated)

public void shutdownNow()

updateSetting(UpdateSettingRequest request) (deprecated)

public final Setting updateSetting(UpdateSettingRequest request)

Updates a setting.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the setting does not exist. Returns a google.rpc.Status with google.rpc.Code.FAILED_PRECONDITION if the setting is flagged as read only. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the setting value.

On success, the response will contain only name, local_value and etag. The metadata and effective_value cannot be updated through this API.

Note: the supplied setting will perform a full overwrite of the local_value field.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   UpdateSettingRequest request =
       UpdateSettingRequest.newBuilder().setSetting(Setting.newBuilder().build()).build();
   Setting response = resourceSettingsServiceClient.updateSetting(request);
 }
 
Parameter
Name Description
request UpdateSettingRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Setting

updateSettingCallable() (deprecated)

public final UnaryCallable<UpdateSettingRequest,Setting> updateSettingCallable()

Updates a setting.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the setting does not exist. Returns a google.rpc.Status with google.rpc.Code.FAILED_PRECONDITION if the setting is flagged as read only. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the setting value.

On success, the response will contain only name, local_value and etag. The metadata and effective_value cannot be updated through this API.

Note: the supplied setting will perform a full overwrite of the local_value field.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ResourceSettingsServiceClient resourceSettingsServiceClient =
     ResourceSettingsServiceClient.create()) {
   UpdateSettingRequest request =
       UpdateSettingRequest.newBuilder().setSetting(Setting.newBuilder().build()).build();
   ApiFuture<Setting> future =
       resourceSettingsServiceClient.updateSettingCallable().futureCall(request);
   // Do something.
   Setting response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateSettingRequest,Setting>