Class OrgPolicyViolationsPreviewServiceClient

java.lang.Object
com.google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewServiceClient
All Implemented Interfaces:
BackgroundResource, AutoCloseable

@Generated("by gapic-generator-java") public class OrgPolicyViolationsPreviewServiceClient extends Object implements BackgroundResource
Service Description: Violations Preview API service for OrgPolicy.

An [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is a preview of the violations that will exist as soon as a proposed OrgPolicy change is submitted. To create an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview], the API user specifies the changes they wish to make and requests the generation of a preview via [GenerateViolationsPreview][]. the OrgPolicy Simulator service then scans the API user's currently existing resources to determine these resources violate the newly set OrgPolicy.

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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
     OrgPolicyViolationsPreviewServiceClient.create()) {
   OrgPolicyViolationsPreviewName name =
       OrgPolicyViolationsPreviewName.of(
           "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]");
   OrgPolicyViolationsPreview response =
       orgPolicyViolationsPreviewServiceClient.getOrgPolicyViolationsPreview(name);
 }
 

Note: close() needs to be called on the OrgPolicyViolationsPreviewServiceClient 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

ListOrgPolicyViolationsPreviews

ListOrgPolicyViolationsPreviews lists each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] in an organization. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

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

  • listOrgPolicyViolationsPreviews(ListOrgPolicyViolationsPreviewsRequest request)

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

  • listOrgPolicyViolationsPreviews(OrganizationLocationName parent)

  • listOrgPolicyViolationsPreviews(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.

  • listOrgPolicyViolationsPreviewsPagedCallable()

  • listOrgPolicyViolationsPreviewsCallable()

GetOrgPolicyViolationsPreview

GetOrgPolicyViolationsPreview gets the specified [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

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

  • getOrgPolicyViolationsPreview(GetOrgPolicyViolationsPreviewRequest request)

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

  • getOrgPolicyViolationsPreview(OrgPolicyViolationsPreviewName name)

  • getOrgPolicyViolationsPreview(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.

  • getOrgPolicyViolationsPreviewCallable()

CreateOrgPolicyViolationsPreview

CreateOrgPolicyViolationsPreview creates an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] for the proposed changes in the provided [OrgPolicyViolationsPreview.OrgPolicyOverlay][]. The changes to OrgPolicy are specified by this `OrgPolicyOverlay`. The resources to scan are inferred from these specified changes.

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

  • createOrgPolicyViolationsPreviewAsync(CreateOrgPolicyViolationsPreviewRequest request)

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

  • createOrgPolicyViolationsPreviewAsync(OrganizationLocationName parent, OrgPolicyViolationsPreview orgPolicyViolationsPreview, String orgPolicyViolationsPreviewId)

  • createOrgPolicyViolationsPreviewAsync(String parent, OrgPolicyViolationsPreview orgPolicyViolationsPreview, String orgPolicyViolationsPreviewId)

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

  • createOrgPolicyViolationsPreviewOperationCallable()

  • createOrgPolicyViolationsPreviewCallable()

ListOrgPolicyViolations

ListOrgPolicyViolations lists the [OrgPolicyViolations][] that are present in an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview].

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

  • listOrgPolicyViolations(ListOrgPolicyViolationsRequest request)

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

  • listOrgPolicyViolations(OrgPolicyViolationsPreviewName parent)

  • listOrgPolicyViolations(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.

  • listOrgPolicyViolationsPagedCallable()

  • listOrgPolicyViolationsCallable()

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 OrgPolicyViolationsPreviewServiceSettings 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
 OrgPolicyViolationsPreviewServiceSettings orgPolicyViolationsPreviewServiceSettings =
     OrgPolicyViolationsPreviewServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
     OrgPolicyViolationsPreviewServiceClient.create(orgPolicyViolationsPreviewServiceSettings);
 

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
 OrgPolicyViolationsPreviewServiceSettings orgPolicyViolationsPreviewServiceSettings =
     OrgPolicyViolationsPreviewServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
     OrgPolicyViolationsPreviewServiceClient.create(orgPolicyViolationsPreviewServiceSettings);
 

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
 OrgPolicyViolationsPreviewServiceSettings orgPolicyViolationsPreviewServiceSettings =
     OrgPolicyViolationsPreviewServiceSettings.newHttpJsonBuilder().build();
 OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
     OrgPolicyViolationsPreviewServiceClient.create(orgPolicyViolationsPreviewServiceSettings);
 

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

  • Constructor Details

    • OrgPolicyViolationsPreviewServiceClient

      protected OrgPolicyViolationsPreviewServiceClient(OrgPolicyViolationsPreviewServiceSettings settings) throws IOException
      Constructs an instance of OrgPolicyViolationsPreviewServiceClient, 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.
      Throws:
      IOException
    • OrgPolicyViolationsPreviewServiceClient

      protected OrgPolicyViolationsPreviewServiceClient(OrgPolicyViolationsPreviewServiceStub stub)
  • Method Details

    • create

      public static final OrgPolicyViolationsPreviewServiceClient create() throws IOException
      Constructs an instance of OrgPolicyViolationsPreviewServiceClient with default settings.
      Throws:
      IOException
    • create

      Constructs an instance of OrgPolicyViolationsPreviewServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
      Throws:
      IOException
    • create

      Constructs an instance of OrgPolicyViolationsPreviewServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(OrgPolicyViolationsPreviewServiceSettings).
    • getSettings

      public final OrgPolicyViolationsPreviewServiceSettings getSettings()
    • getStub

    • getOperationsClient

      public final OperationsClient getOperationsClient()
      Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
    • getHttpJsonOperationsClient

      @BetaApi public final OperationsClient getHttpJsonOperationsClient()
      Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
    • listOrgPolicyViolationsPreviews

      ListOrgPolicyViolationsPreviews lists each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] in an organization. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
         for (OrgPolicyViolationsPreview element :
             orgPolicyViolationsPreviewServiceClient
                 .listOrgPolicyViolationsPreviews(parent)
                 .iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The parent the violations are scoped to. Format: `organizations/{organization}/locations/{location}`

      Example: `organizations/my-example-org/locations/global`

      Throws:
      ApiException - if the remote call fails
    • listOrgPolicyViolationsPreviews

      ListOrgPolicyViolationsPreviews lists each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] in an organization. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         String parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
         for (OrgPolicyViolationsPreview element :
             orgPolicyViolationsPreviewServiceClient
                 .listOrgPolicyViolationsPreviews(parent)
                 .iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The parent the violations are scoped to. Format: `organizations/{organization}/locations/{location}`

      Example: `organizations/my-example-org/locations/global`

      Throws:
      ApiException - if the remote call fails
    • listOrgPolicyViolationsPreviews

      ListOrgPolicyViolationsPreviews lists each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] in an organization. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         ListOrgPolicyViolationsPreviewsRequest request =
             ListOrgPolicyViolationsPreviewsRequest.newBuilder()
                 .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         for (OrgPolicyViolationsPreview element :
             orgPolicyViolationsPreviewServiceClient
                 .listOrgPolicyViolationsPreviews(request)
                 .iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • listOrgPolicyViolationsPreviewsPagedCallable

      ListOrgPolicyViolationsPreviews lists each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] in an organization. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         ListOrgPolicyViolationsPreviewsRequest request =
             ListOrgPolicyViolationsPreviewsRequest.newBuilder()
                 .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         ApiFuture<OrgPolicyViolationsPreview> future =
             orgPolicyViolationsPreviewServiceClient
                 .listOrgPolicyViolationsPreviewsPagedCallable()
                 .futureCall(request);
         // Do something.
         for (OrgPolicyViolationsPreview element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listOrgPolicyViolationsPreviewsCallable

      public final UnaryCallable<ListOrgPolicyViolationsPreviewsRequest,ListOrgPolicyViolationsPreviewsResponse> listOrgPolicyViolationsPreviewsCallable()
      ListOrgPolicyViolationsPreviews lists each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] in an organization. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         ListOrgPolicyViolationsPreviewsRequest request =
             ListOrgPolicyViolationsPreviewsRequest.newBuilder()
                 .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         while (true) {
           ListOrgPolicyViolationsPreviewsResponse response =
               orgPolicyViolationsPreviewServiceClient
                   .listOrgPolicyViolationsPreviewsCallable()
                   .call(request);
           for (OrgPolicyViolationsPreview element : response.getOrgPolicyViolationsPreviewsList()) {
             // doThingsWith(element);
           }
           String nextPageToken = response.getNextPageToken();
           if (!Strings.isNullOrEmpty(nextPageToken)) {
             request = request.toBuilder().setPageToken(nextPageToken).build();
           } else {
             break;
           }
         }
       }
       
    • getOrgPolicyViolationsPreview

      public final OrgPolicyViolationsPreview getOrgPolicyViolationsPreview(OrgPolicyViolationsPreviewName name)
      GetOrgPolicyViolationsPreview gets the specified [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         OrgPolicyViolationsPreviewName name =
             OrgPolicyViolationsPreviewName.of(
                 "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]");
         OrgPolicyViolationsPreview response =
             orgPolicyViolationsPreviewServiceClient.getOrgPolicyViolationsPreview(name);
       }
       
      Parameters:
      name - Required. The name of the OrgPolicyViolationsPreview to get.
      Throws:
      ApiException - if the remote call fails
    • getOrgPolicyViolationsPreview

      public final OrgPolicyViolationsPreview getOrgPolicyViolationsPreview(String name)
      GetOrgPolicyViolationsPreview gets the specified [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         String name =
             OrgPolicyViolationsPreviewName.of(
                     "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]")
                 .toString();
         OrgPolicyViolationsPreview response =
             orgPolicyViolationsPreviewServiceClient.getOrgPolicyViolationsPreview(name);
       }
       
      Parameters:
      name - Required. The name of the OrgPolicyViolationsPreview to get.
      Throws:
      ApiException - if the remote call fails
    • getOrgPolicyViolationsPreview

      public final OrgPolicyViolationsPreview getOrgPolicyViolationsPreview(GetOrgPolicyViolationsPreviewRequest request)
      GetOrgPolicyViolationsPreview gets the specified [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         GetOrgPolicyViolationsPreviewRequest request =
             GetOrgPolicyViolationsPreviewRequest.newBuilder()
                 .setName(
                     OrgPolicyViolationsPreviewName.of(
                             "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]")
                         .toString())
                 .build();
         OrgPolicyViolationsPreview response =
             orgPolicyViolationsPreviewServiceClient.getOrgPolicyViolationsPreview(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getOrgPolicyViolationsPreviewCallable

      public final UnaryCallable<GetOrgPolicyViolationsPreviewRequest,OrgPolicyViolationsPreview> getOrgPolicyViolationsPreviewCallable()
      GetOrgPolicyViolationsPreview gets the specified [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]. Each [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] is available for at least 7 days.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         GetOrgPolicyViolationsPreviewRequest request =
             GetOrgPolicyViolationsPreviewRequest.newBuilder()
                 .setName(
                     OrgPolicyViolationsPreviewName.of(
                             "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]")
                         .toString())
                 .build();
         ApiFuture<OrgPolicyViolationsPreview> future =
             orgPolicyViolationsPreviewServiceClient
                 .getOrgPolicyViolationsPreviewCallable()
                 .futureCall(request);
         // Do something.
         OrgPolicyViolationsPreview response = future.get();
       }
       
    • createOrgPolicyViolationsPreviewAsync

      public final OperationFuture<OrgPolicyViolationsPreview,CreateOrgPolicyViolationsPreviewOperationMetadata> createOrgPolicyViolationsPreviewAsync(OrganizationLocationName parent, OrgPolicyViolationsPreview orgPolicyViolationsPreview, String orgPolicyViolationsPreviewId)
      CreateOrgPolicyViolationsPreview creates an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] for the proposed changes in the provided [OrgPolicyViolationsPreview.OrgPolicyOverlay][]. The changes to OrgPolicy are specified by this `OrgPolicyOverlay`. The resources to scan are inferred from these specified changes.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
         OrgPolicyViolationsPreview orgPolicyViolationsPreview =
             OrgPolicyViolationsPreview.newBuilder().build();
         String orgPolicyViolationsPreviewId = "orgPolicyViolationsPreviewId2098912671";
         OrgPolicyViolationsPreview response =
             orgPolicyViolationsPreviewServiceClient
                 .createOrgPolicyViolationsPreviewAsync(
                     parent, orgPolicyViolationsPreview, orgPolicyViolationsPreviewId)
                 .get();
       }
       
      Parameters:
      parent - Required. The organization under which this [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] will be created.

      Example: `organizations/my-example-org/locations/global`

      orgPolicyViolationsPreview - Required. The [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] to generate.
      orgPolicyViolationsPreviewId - Optional. An optional user-specified ID for the [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]. If not provided, a random ID will be generated.
      Throws:
      ApiException - if the remote call fails
    • createOrgPolicyViolationsPreviewAsync

      public final OperationFuture<OrgPolicyViolationsPreview,CreateOrgPolicyViolationsPreviewOperationMetadata> createOrgPolicyViolationsPreviewAsync(String parent, OrgPolicyViolationsPreview orgPolicyViolationsPreview, String orgPolicyViolationsPreviewId)
      CreateOrgPolicyViolationsPreview creates an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] for the proposed changes in the provided [OrgPolicyViolationsPreview.OrgPolicyOverlay][]. The changes to OrgPolicy are specified by this `OrgPolicyOverlay`. The resources to scan are inferred from these specified changes.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         String parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
         OrgPolicyViolationsPreview orgPolicyViolationsPreview =
             OrgPolicyViolationsPreview.newBuilder().build();
         String orgPolicyViolationsPreviewId = "orgPolicyViolationsPreviewId2098912671";
         OrgPolicyViolationsPreview response =
             orgPolicyViolationsPreviewServiceClient
                 .createOrgPolicyViolationsPreviewAsync(
                     parent, orgPolicyViolationsPreview, orgPolicyViolationsPreviewId)
                 .get();
       }
       
      Parameters:
      parent - Required. The organization under which this [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] will be created.

      Example: `organizations/my-example-org/locations/global`

      orgPolicyViolationsPreview - Required. The [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] to generate.
      orgPolicyViolationsPreviewId - Optional. An optional user-specified ID for the [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]. If not provided, a random ID will be generated.
      Throws:
      ApiException - if the remote call fails
    • createOrgPolicyViolationsPreviewAsync

      CreateOrgPolicyViolationsPreview creates an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] for the proposed changes in the provided [OrgPolicyViolationsPreview.OrgPolicyOverlay][]. The changes to OrgPolicy are specified by this `OrgPolicyOverlay`. The resources to scan are inferred from these specified changes.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         CreateOrgPolicyViolationsPreviewRequest request =
             CreateOrgPolicyViolationsPreviewRequest.newBuilder()
                 .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
                 .setOrgPolicyViolationsPreview(OrgPolicyViolationsPreview.newBuilder().build())
                 .setOrgPolicyViolationsPreviewId("orgPolicyViolationsPreviewId2098912671")
                 .build();
         OrgPolicyViolationsPreview response =
             orgPolicyViolationsPreviewServiceClient
                 .createOrgPolicyViolationsPreviewAsync(request)
                 .get();
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • createOrgPolicyViolationsPreviewOperationCallable

      CreateOrgPolicyViolationsPreview creates an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] for the proposed changes in the provided [OrgPolicyViolationsPreview.OrgPolicyOverlay][]. The changes to OrgPolicy are specified by this `OrgPolicyOverlay`. The resources to scan are inferred from these specified changes.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         CreateOrgPolicyViolationsPreviewRequest request =
             CreateOrgPolicyViolationsPreviewRequest.newBuilder()
                 .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
                 .setOrgPolicyViolationsPreview(OrgPolicyViolationsPreview.newBuilder().build())
                 .setOrgPolicyViolationsPreviewId("orgPolicyViolationsPreviewId2098912671")
                 .build();
         OperationFuture<OrgPolicyViolationsPreview, CreateOrgPolicyViolationsPreviewOperationMetadata>
             future =
                 orgPolicyViolationsPreviewServiceClient
                     .createOrgPolicyViolationsPreviewOperationCallable()
                     .futureCall(request);
         // Do something.
         OrgPolicyViolationsPreview response = future.get();
       }
       
    • createOrgPolicyViolationsPreviewCallable

      public final UnaryCallable<CreateOrgPolicyViolationsPreviewRequest,Operation> createOrgPolicyViolationsPreviewCallable()
      CreateOrgPolicyViolationsPreview creates an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview] for the proposed changes in the provided [OrgPolicyViolationsPreview.OrgPolicyOverlay][]. The changes to OrgPolicy are specified by this `OrgPolicyOverlay`. The resources to scan are inferred from these specified changes.

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         CreateOrgPolicyViolationsPreviewRequest request =
             CreateOrgPolicyViolationsPreviewRequest.newBuilder()
                 .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
                 .setOrgPolicyViolationsPreview(OrgPolicyViolationsPreview.newBuilder().build())
                 .setOrgPolicyViolationsPreviewId("orgPolicyViolationsPreviewId2098912671")
                 .build();
         ApiFuture<Operation> future =
             orgPolicyViolationsPreviewServiceClient
                 .createOrgPolicyViolationsPreviewCallable()
                 .futureCall(request);
         // Do something.
         Operation response = future.get();
       }
       
    • listOrgPolicyViolations

      ListOrgPolicyViolations lists the [OrgPolicyViolations][] that are present in an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview].

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         OrgPolicyViolationsPreviewName parent =
             OrgPolicyViolationsPreviewName.of(
                 "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]");
         for (OrgPolicyViolation element :
             orgPolicyViolationsPreviewServiceClient.listOrgPolicyViolations(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The OrgPolicyViolationsPreview to get OrgPolicyViolations from. Format: organizations/{organization}/locations/{location}/orgPolicyViolationsPreviews/{orgPolicyViolationsPreview}
      Throws:
      ApiException - if the remote call fails
    • listOrgPolicyViolations

      ListOrgPolicyViolations lists the [OrgPolicyViolations][] that are present in an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview].

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         String parent =
             OrgPolicyViolationsPreviewName.of(
                     "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]")
                 .toString();
         for (OrgPolicyViolation element :
             orgPolicyViolationsPreviewServiceClient.listOrgPolicyViolations(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The OrgPolicyViolationsPreview to get OrgPolicyViolations from. Format: organizations/{organization}/locations/{location}/orgPolicyViolationsPreviews/{orgPolicyViolationsPreview}
      Throws:
      ApiException - if the remote call fails
    • listOrgPolicyViolations

      ListOrgPolicyViolations lists the [OrgPolicyViolations][] that are present in an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview].

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         ListOrgPolicyViolationsRequest request =
             ListOrgPolicyViolationsRequest.newBuilder()
                 .setParent(
                     OrgPolicyViolationsPreviewName.of(
                             "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]")
                         .toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         for (OrgPolicyViolation element :
             orgPolicyViolationsPreviewServiceClient.listOrgPolicyViolations(request).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • listOrgPolicyViolationsPagedCallable

      ListOrgPolicyViolations lists the [OrgPolicyViolations][] that are present in an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview].

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         ListOrgPolicyViolationsRequest request =
             ListOrgPolicyViolationsRequest.newBuilder()
                 .setParent(
                     OrgPolicyViolationsPreviewName.of(
                             "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]")
                         .toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         ApiFuture<OrgPolicyViolation> future =
             orgPolicyViolationsPreviewServiceClient
                 .listOrgPolicyViolationsPagedCallable()
                 .futureCall(request);
         // Do something.
         for (OrgPolicyViolation element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listOrgPolicyViolationsCallable

      public final UnaryCallable<ListOrgPolicyViolationsRequest,ListOrgPolicyViolationsResponse> listOrgPolicyViolationsCallable()
      ListOrgPolicyViolations lists the [OrgPolicyViolations][] that are present in an [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview].

      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 (OrgPolicyViolationsPreviewServiceClient orgPolicyViolationsPreviewServiceClient =
           OrgPolicyViolationsPreviewServiceClient.create()) {
         ListOrgPolicyViolationsRequest request =
             ListOrgPolicyViolationsRequest.newBuilder()
                 .setParent(
                     OrgPolicyViolationsPreviewName.of(
                             "[ORGANIZATION]", "[LOCATION]", "[ORG_POLICY_VIOLATIONS_PREVIEW]")
                         .toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         while (true) {
           ListOrgPolicyViolationsResponse response =
               orgPolicyViolationsPreviewServiceClient.listOrgPolicyViolationsCallable().call(request);
           for (OrgPolicyViolation element : response.getOrgPolicyViolationsList()) {
             // doThingsWith(element);
           }
           String nextPageToken = response.getNextPageToken();
           if (!Strings.isNullOrEmpty(nextPageToken)) {
             request = request.toBuilder().setPageToken(nextPageToken).build();
           } else {
             break;
           }
         }
       }
       
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface BackgroundResource
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface BackgroundResource
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface BackgroundResource
    • shutdownNow

      public void shutdownNow()
      Specified by:
      shutdownNow in interface BackgroundResource
    • awaitTermination

      public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface BackgroundResource
      Throws:
      InterruptedException