@Generated(value="by gapic-generator-java") public class ResourceSettingsServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
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.
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().
| 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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return 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 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
ResourceSettingsServiceClient.ListSettingsFixedSizeCollection |
static class |
ResourceSettingsServiceClient.ListSettingsPage |
static class |
ResourceSettingsServiceClient.ListSettingsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
ResourceSettingsServiceClient(ResourceSettingsServiceSettings settings)
Constructs an instance of ResourceSettingsServiceClient, using the given settings.
|
protected |
ResourceSettingsServiceClient(ResourceSettingsServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ResourceSettingsServiceClient |
create()
Constructs an instance of ResourceSettingsServiceClient with default settings.
|
static ResourceSettingsServiceClient |
create(ResourceSettingsServiceSettings settings)
Constructs an instance of ResourceSettingsServiceClient, using the given settings.
|
static ResourceSettingsServiceClient |
create(ResourceSettingsServiceStub stub)
Constructs an instance of ResourceSettingsServiceClient, using the given stub for making calls.
|
Setting |
getSetting(GetSettingRequest request)
Gets a setting.
|
Setting |
getSetting(SettingName name)
Gets a setting.
|
Setting |
getSetting(String name)
Gets a setting.
|
com.google.api.gax.rpc.UnaryCallable<GetSettingRequest,Setting> |
getSettingCallable()
Gets a setting.
|
ResourceSettingsServiceSettings |
getSettings() |
ResourceSettingsServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ResourceSettingsServiceClient.ListSettingsPagedResponse |
listSettings(ListSettingsRequest request)
Lists all the settings that are available on the Cloud resource `parent`.
|
ResourceSettingsServiceClient.ListSettingsPagedResponse |
listSettings(com.google.api.resourcenames.ResourceName parent)
Lists all the settings that are available on the Cloud resource `parent`.
|
ResourceSettingsServiceClient.ListSettingsPagedResponse |
listSettings(String parent)
Lists all the settings that are available on the Cloud resource `parent`.
|
com.google.api.gax.rpc.UnaryCallable<ListSettingsRequest,ListSettingsResponse> |
listSettingsCallable()
Lists all the settings that are available on the Cloud resource `parent`.
|
com.google.api.gax.rpc.UnaryCallable<ListSettingsRequest,ResourceSettingsServiceClient.ListSettingsPagedResponse> |
listSettingsPagedCallable()
Lists all the settings that are available on the Cloud resource `parent`.
|
void |
shutdown() |
void |
shutdownNow() |
Setting |
updateSetting(UpdateSettingRequest request)
Updates a setting.
|
com.google.api.gax.rpc.UnaryCallable<UpdateSettingRequest,Setting> |
updateSettingCallable()
Updates a setting.
|
protected ResourceSettingsServiceClient(ResourceSettingsServiceSettings settings) throws IOException
IOExceptionprotected ResourceSettingsServiceClient(ResourceSettingsServiceStub stub)
public static final ResourceSettingsServiceClient create() throws IOException
IOExceptionpublic static final ResourceSettingsServiceClient create(ResourceSettingsServiceSettings settings) throws IOException
IOExceptionpublic static final ResourceSettingsServiceClient create(ResourceSettingsServiceStub stub)
public final ResourceSettingsServiceSettings getSettings()
public ResourceSettingsServiceStub getStub()
public final ResourceSettingsServiceClient.ListSettingsPagedResponse listSettings(com.google.api.resourcenames.ResourceName 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);
}
}
parent - Required. The Cloud resource that parents the setting. Must be in one of the
following forms:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ResourceSettingsServiceClient.ListSettingsPagedResponse listSettings(String 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);
}
}
parent - Required. The Cloud resource that parents the setting. Must be in one of the
following forms:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ResourceSettingsServiceClient.ListSettingsPagedResponse listSettings(ListSettingsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListSettingsRequest,ResourceSettingsServiceClient.ListSettingsPagedResponse> listSettingsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListSettingsRequest,ListSettingsResponse> listSettingsCallable()
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;
}
}
}
public final Setting getSetting(SettingName name)
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);
}
name - Required. The name of the setting to get. See
[Setting][google.cloud.resourcesettings.v1.Setting] for naming requirements.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Setting getSetting(String name)
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);
}
name - Required. The name of the setting to get. See
[Setting][google.cloud.resourcesettings.v1.Setting] for naming requirements.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Setting getSetting(GetSettingRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetSettingRequest,Setting> getSettingCallable()
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();
}
public final Setting updateSetting(UpdateSettingRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateSettingRequest,Setting> updateSettingCallable()
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();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2024 Google LLC. All rights reserved.