@Generated(value="by gapic-generator-java") public class SystemPolicyV1Client extends Object implements com.google.api.gax.core.BackgroundResource
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 for illustrative purposes only.
// It may require modifications to work in your environment.
try (SystemPolicyV1Client systemPolicyV1Client = SystemPolicyV1Client.create()) {
PolicyName name = PolicyName.ofLocationName("[LOCATION]");
Resources.Policy response = systemPolicyV1Client.getSystemPolicy(name);
}
Note: close() needs to be called on the SystemPolicyV1Client 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:
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 SystemPolicyV1Settings to create(). For example:
To customize credentials:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
SystemPolicyV1Settings systemPolicyV1Settings =
SystemPolicyV1Settings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SystemPolicyV1Client systemPolicyV1Client = SystemPolicyV1Client.create(systemPolicyV1Settings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
SystemPolicyV1Settings systemPolicyV1Settings =
SystemPolicyV1Settings.newBuilder().setEndpoint(myEndpoint).build();
SystemPolicyV1Client systemPolicyV1Client = SystemPolicyV1Client.create(systemPolicyV1Settings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
SystemPolicyV1Settings systemPolicyV1Settings =
SystemPolicyV1Settings.newBuilder()
.setTransportChannelProvider(
SystemPolicyV1Settings.defaultHttpJsonTransportProviderBuilder().build())
.build();
SystemPolicyV1Client systemPolicyV1Client = SystemPolicyV1Client.create(systemPolicyV1Settings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier | Constructor and Description |
|---|---|
protected |
SystemPolicyV1Client(SystemPolicyV1Settings settings)
Constructs an instance of SystemPolicyV1Client, using the given settings.
|
protected |
SystemPolicyV1Client(SystemPolicyV1Stub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static SystemPolicyV1Client |
create()
Constructs an instance of SystemPolicyV1Client with default settings.
|
static SystemPolicyV1Client |
create(SystemPolicyV1Settings settings)
Constructs an instance of SystemPolicyV1Client, using the given settings.
|
static SystemPolicyV1Client |
create(SystemPolicyV1Stub stub)
Constructs an instance of SystemPolicyV1Client, using the given stub for making calls.
|
SystemPolicyV1Settings |
getSettings() |
SystemPolicyV1Stub |
getStub() |
Resources.Policy |
getSystemPolicy(PolicyName name)
Gets the current system policy in the specified location.
|
Resources.Policy |
getSystemPolicy(Service.GetSystemPolicyRequest request)
Gets the current system policy in the specified location.
|
Resources.Policy |
getSystemPolicy(String name)
Gets the current system policy in the specified location.
|
com.google.api.gax.rpc.UnaryCallable<Service.GetSystemPolicyRequest,Resources.Policy> |
getSystemPolicyCallable()
Gets the current system policy in the specified location.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
void |
shutdownNow() |
protected SystemPolicyV1Client(SystemPolicyV1Settings settings) throws IOException
IOExceptionprotected SystemPolicyV1Client(SystemPolicyV1Stub stub)
public static final SystemPolicyV1Client create() throws IOException
IOExceptionpublic static final SystemPolicyV1Client create(SystemPolicyV1Settings settings) throws IOException
IOExceptionpublic static final SystemPolicyV1Client create(SystemPolicyV1Stub stub)
public final SystemPolicyV1Settings getSettings()
public SystemPolicyV1Stub getStub()
public final Resources.Policy getSystemPolicy(PolicyName name)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (SystemPolicyV1Client systemPolicyV1Client = SystemPolicyV1Client.create()) {
PolicyName name = PolicyName.ofLocationName("[LOCATION]");
Resources.Policy response = systemPolicyV1Client.getSystemPolicy(name);
}
name - Required. The resource name, in the format `locations/*/policy`. Note that the
system policy is not associated with a project.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Resources.Policy getSystemPolicy(String name)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (SystemPolicyV1Client systemPolicyV1Client = SystemPolicyV1Client.create()) {
String name = PolicyName.ofProjectName("[PROJECT]").toString();
Resources.Policy response = systemPolicyV1Client.getSystemPolicy(name);
}
name - Required. The resource name, in the format `locations/*/policy`. Note that the
system policy is not associated with a project.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Resources.Policy getSystemPolicy(Service.GetSystemPolicyRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (SystemPolicyV1Client systemPolicyV1Client = SystemPolicyV1Client.create()) {
Service.GetSystemPolicyRequest request =
Service.GetSystemPolicyRequest.newBuilder()
.setName(PolicyName.ofLocationName("[LOCATION]").toString())
.build();
Resources.Policy response = systemPolicyV1Client.getSystemPolicy(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<Service.GetSystemPolicyRequest,Resources.Policy> getSystemPolicyCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (SystemPolicyV1Client systemPolicyV1Client = SystemPolicyV1Client.create()) {
Service.GetSystemPolicyRequest request =
Service.GetSystemPolicyRequest.newBuilder()
.setName(PolicyName.ofLocationName("[LOCATION]").toString())
.build();
ApiFuture<Resources.Policy> future =
systemPolicyV1Client.getSystemPolicyCallable().futureCall(request);
// Do something.
Resources.Policy 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 © 2022 Google LLC. All rights reserved.