Class DnsThreatDetectorServiceClient

java.lang.Object
com.google.cloud.networksecurity.v1beta1.DnsThreatDetectorServiceClient
All Implemented Interfaces:
BackgroundResource, AutoCloseable

@BetaApi @Generated("by gapic-generator-java") public class DnsThreatDetectorServiceClient extends Object implements BackgroundResource
Service Description: The Network Security API for DNS Threat Detectors.

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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
     DnsThreatDetectorServiceClient.create()) {
   DnsThreatDetectorName name =
       DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]");
   DnsThreatDetector response = dnsThreatDetectorServiceClient.getDnsThreatDetector(name);
 }
 

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

ListDnsThreatDetectors

Lists DnsThreatDetectors in a given project and location.

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

  • listDnsThreatDetectors(ListDnsThreatDetectorsRequest request)

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

  • listDnsThreatDetectors(LocationName parent)

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

  • listDnsThreatDetectorsPagedCallable()

  • listDnsThreatDetectorsCallable()

GetDnsThreatDetector

Gets the details of a single DnsThreatDetector.

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

  • getDnsThreatDetector(GetDnsThreatDetectorRequest request)

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

  • getDnsThreatDetector(DnsThreatDetectorName name)

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

  • getDnsThreatDetectorCallable()

CreateDnsThreatDetector

Creates a new DnsThreatDetector in a given project and location.

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

  • createDnsThreatDetector(CreateDnsThreatDetectorRequest request)

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

  • createDnsThreatDetector(LocationName parent, DnsThreatDetector dnsThreatDetector, String dnsThreatDetectorId)

  • createDnsThreatDetector(String parent, DnsThreatDetector dnsThreatDetector, String dnsThreatDetectorId)

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

  • createDnsThreatDetectorCallable()

UpdateDnsThreatDetector

Updates a single DnsThreatDetector.

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

  • updateDnsThreatDetector(UpdateDnsThreatDetectorRequest request)

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

  • updateDnsThreatDetector(DnsThreatDetector dnsThreatDetector, FieldMask updateMask)

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

  • updateDnsThreatDetectorCallable()

DeleteDnsThreatDetector

Deletes a single DnsThreatDetector.

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

  • deleteDnsThreatDetector(DeleteDnsThreatDetectorRequest request)

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

  • deleteDnsThreatDetector(DnsThreatDetectorName name)

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

  • deleteDnsThreatDetectorCallable()

ListLocations

Lists information about the supported locations for this service.

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

  • listLocations(ListLocationsRequest request)

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

  • listLocationsPagedCallable()

  • listLocationsCallable()

GetLocation

Gets information about a location.

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

  • getLocation(GetLocationRequest request)

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

  • getLocationCallable()

SetIamPolicy

Sets the access control policy on the specified resource. Replacesany existing policy.

Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

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

  • setIamPolicy(SetIamPolicyRequest request)

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

  • setIamPolicyCallable()

GetIamPolicy

Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

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

  • getIamPolicy(GetIamPolicyRequest request)

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

  • getIamPolicyCallable()

TestIamPermissions

Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.

Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

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

  • testIamPermissions(TestIamPermissionsRequest request)

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

  • testIamPermissionsCallable()

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 DnsThreatDetectorServiceSettings 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
 DnsThreatDetectorServiceSettings dnsThreatDetectorServiceSettings =
     DnsThreatDetectorServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
     DnsThreatDetectorServiceClient.create(dnsThreatDetectorServiceSettings);
 

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
 DnsThreatDetectorServiceSettings dnsThreatDetectorServiceSettings =
     DnsThreatDetectorServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
     DnsThreatDetectorServiceClient.create(dnsThreatDetectorServiceSettings);
 

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
 DnsThreatDetectorServiceSettings dnsThreatDetectorServiceSettings =
     DnsThreatDetectorServiceSettings.newHttpJsonBuilder().build();
 DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
     DnsThreatDetectorServiceClient.create(dnsThreatDetectorServiceSettings);
 

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

  • Constructor Details

    • DnsThreatDetectorServiceClient

      protected DnsThreatDetectorServiceClient(DnsThreatDetectorServiceSettings settings) throws IOException
      Constructs an instance of DnsThreatDetectorServiceClient, 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
    • DnsThreatDetectorServiceClient

      protected DnsThreatDetectorServiceClient(DnsThreatDetectorServiceStub stub)
  • Method Details

    • create

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

      public static final DnsThreatDetectorServiceClient create(DnsThreatDetectorServiceSettings settings) throws IOException
      Constructs an instance of DnsThreatDetectorServiceClient, 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 DnsThreatDetectorServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(DnsThreatDetectorServiceSettings).
    • getSettings

      public final DnsThreatDetectorServiceSettings getSettings()
    • getStub

      public DnsThreatDetectorServiceStub getStub()
    • listDnsThreatDetectors

      Lists DnsThreatDetectors in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         for (DnsThreatDetector element :
             dnsThreatDetectorServiceClient.listDnsThreatDetectors(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The parent value for `ListDnsThreatDetectorsRequest`.
      Throws:
      ApiException - if the remote call fails
    • listDnsThreatDetectors

      public final DnsThreatDetectorServiceClient.ListDnsThreatDetectorsPagedResponse listDnsThreatDetectors(String parent)
      Lists DnsThreatDetectors in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
         for (DnsThreatDetector element :
             dnsThreatDetectorServiceClient.listDnsThreatDetectors(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The parent value for `ListDnsThreatDetectorsRequest`.
      Throws:
      ApiException - if the remote call fails
    • listDnsThreatDetectors

      Lists DnsThreatDetectors in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         ListDnsThreatDetectorsRequest request =
             ListDnsThreatDetectorsRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         for (DnsThreatDetector element :
             dnsThreatDetectorServiceClient.listDnsThreatDetectors(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
    • listDnsThreatDetectorsPagedCallable

      Lists DnsThreatDetectors in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         ListDnsThreatDetectorsRequest request =
             ListDnsThreatDetectorsRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         ApiFuture<DnsThreatDetector> future =
             dnsThreatDetectorServiceClient.listDnsThreatDetectorsPagedCallable().futureCall(request);
         // Do something.
         for (DnsThreatDetector element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listDnsThreatDetectorsCallable

      public final UnaryCallable<ListDnsThreatDetectorsRequest,ListDnsThreatDetectorsResponse> listDnsThreatDetectorsCallable()
      Lists DnsThreatDetectors in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         ListDnsThreatDetectorsRequest request =
             ListDnsThreatDetectorsRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         while (true) {
           ListDnsThreatDetectorsResponse response =
               dnsThreatDetectorServiceClient.listDnsThreatDetectorsCallable().call(request);
           for (DnsThreatDetector element : response.getDnsThreatDetectorsList()) {
             // doThingsWith(element);
           }
           String nextPageToken = response.getNextPageToken();
           if (!Strings.isNullOrEmpty(nextPageToken)) {
             request = request.toBuilder().setPageToken(nextPageToken).build();
           } else {
             break;
           }
         }
       }
       
    • getDnsThreatDetector

      public final DnsThreatDetector getDnsThreatDetector(DnsThreatDetectorName name)
      Gets the details of a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         DnsThreatDetectorName name =
             DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]");
         DnsThreatDetector response = dnsThreatDetectorServiceClient.getDnsThreatDetector(name);
       }
       
      Parameters:
      name - Required. Name of the DnsThreatDetector resource.
      Throws:
      ApiException - if the remote call fails
    • getDnsThreatDetector

      public final DnsThreatDetector getDnsThreatDetector(String name)
      Gets the details of a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         String name =
             DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]").toString();
         DnsThreatDetector response = dnsThreatDetectorServiceClient.getDnsThreatDetector(name);
       }
       
      Parameters:
      name - Required. Name of the DnsThreatDetector resource.
      Throws:
      ApiException - if the remote call fails
    • getDnsThreatDetector

      public final DnsThreatDetector getDnsThreatDetector(GetDnsThreatDetectorRequest request)
      Gets the details of a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         GetDnsThreatDetectorRequest request =
             GetDnsThreatDetectorRequest.newBuilder()
                 .setName(
                     DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]")
                         .toString())
                 .build();
         DnsThreatDetector response = dnsThreatDetectorServiceClient.getDnsThreatDetector(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getDnsThreatDetectorCallable

      public final UnaryCallable<GetDnsThreatDetectorRequest,DnsThreatDetector> getDnsThreatDetectorCallable()
      Gets the details of a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         GetDnsThreatDetectorRequest request =
             GetDnsThreatDetectorRequest.newBuilder()
                 .setName(
                     DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]")
                         .toString())
                 .build();
         ApiFuture<DnsThreatDetector> future =
             dnsThreatDetectorServiceClient.getDnsThreatDetectorCallable().futureCall(request);
         // Do something.
         DnsThreatDetector response = future.get();
       }
       
    • createDnsThreatDetector

      public final DnsThreatDetector createDnsThreatDetector(LocationName parent, DnsThreatDetector dnsThreatDetector, String dnsThreatDetectorId)
      Creates a new DnsThreatDetector in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         DnsThreatDetector dnsThreatDetector = DnsThreatDetector.newBuilder().build();
         String dnsThreatDetectorId = "dnsThreatDetectorId-1579667324";
         DnsThreatDetector response =
             dnsThreatDetectorServiceClient.createDnsThreatDetector(
                 parent, dnsThreatDetector, dnsThreatDetectorId);
       }
       
      Parameters:
      parent - Required. The value for the parent of the DnsThreatDetector resource.
      dnsThreatDetector - Required. The `DnsThreatDetector` resource to create.
      dnsThreatDetectorId - Optional. The ID of the requesting DnsThreatDetector object. If this field is not supplied, the service generates an identifier.
      Throws:
      ApiException - if the remote call fails
    • createDnsThreatDetector

      public final DnsThreatDetector createDnsThreatDetector(String parent, DnsThreatDetector dnsThreatDetector, String dnsThreatDetectorId)
      Creates a new DnsThreatDetector in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
         DnsThreatDetector dnsThreatDetector = DnsThreatDetector.newBuilder().build();
         String dnsThreatDetectorId = "dnsThreatDetectorId-1579667324";
         DnsThreatDetector response =
             dnsThreatDetectorServiceClient.createDnsThreatDetector(
                 parent, dnsThreatDetector, dnsThreatDetectorId);
       }
       
      Parameters:
      parent - Required. The value for the parent of the DnsThreatDetector resource.
      dnsThreatDetector - Required. The `DnsThreatDetector` resource to create.
      dnsThreatDetectorId - Optional. The ID of the requesting DnsThreatDetector object. If this field is not supplied, the service generates an identifier.
      Throws:
      ApiException - if the remote call fails
    • createDnsThreatDetector

      public final DnsThreatDetector createDnsThreatDetector(CreateDnsThreatDetectorRequest request)
      Creates a new DnsThreatDetector in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         CreateDnsThreatDetectorRequest request =
             CreateDnsThreatDetectorRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setDnsThreatDetectorId("dnsThreatDetectorId-1579667324")
                 .setDnsThreatDetector(DnsThreatDetector.newBuilder().build())
                 .build();
         DnsThreatDetector response = dnsThreatDetectorServiceClient.createDnsThreatDetector(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • createDnsThreatDetectorCallable

      public final UnaryCallable<CreateDnsThreatDetectorRequest,DnsThreatDetector> createDnsThreatDetectorCallable()
      Creates a new DnsThreatDetector in a given project and location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         CreateDnsThreatDetectorRequest request =
             CreateDnsThreatDetectorRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setDnsThreatDetectorId("dnsThreatDetectorId-1579667324")
                 .setDnsThreatDetector(DnsThreatDetector.newBuilder().build())
                 .build();
         ApiFuture<DnsThreatDetector> future =
             dnsThreatDetectorServiceClient.createDnsThreatDetectorCallable().futureCall(request);
         // Do something.
         DnsThreatDetector response = future.get();
       }
       
    • updateDnsThreatDetector

      public final DnsThreatDetector updateDnsThreatDetector(DnsThreatDetector dnsThreatDetector, com.google.protobuf.FieldMask updateMask)
      Updates a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         DnsThreatDetector dnsThreatDetector = DnsThreatDetector.newBuilder().build();
         FieldMask updateMask = FieldMask.newBuilder().build();
         DnsThreatDetector response =
             dnsThreatDetectorServiceClient.updateDnsThreatDetector(dnsThreatDetector, updateMask);
       }
       
      Parameters:
      dnsThreatDetector - Required. The DnsThreatDetector resource being updated.
      updateMask - Optional. The field mask is used to specify the fields to be overwritten in the DnsThreatDetector resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the mask is not provided then all fields present in the request will be overwritten.
      Throws:
      ApiException - if the remote call fails
    • updateDnsThreatDetector

      public final DnsThreatDetector updateDnsThreatDetector(UpdateDnsThreatDetectorRequest request)
      Updates a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         UpdateDnsThreatDetectorRequest request =
             UpdateDnsThreatDetectorRequest.newBuilder()
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .setDnsThreatDetector(DnsThreatDetector.newBuilder().build())
                 .build();
         DnsThreatDetector response = dnsThreatDetectorServiceClient.updateDnsThreatDetector(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • updateDnsThreatDetectorCallable

      public final UnaryCallable<UpdateDnsThreatDetectorRequest,DnsThreatDetector> updateDnsThreatDetectorCallable()
      Updates a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         UpdateDnsThreatDetectorRequest request =
             UpdateDnsThreatDetectorRequest.newBuilder()
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .setDnsThreatDetector(DnsThreatDetector.newBuilder().build())
                 .build();
         ApiFuture<DnsThreatDetector> future =
             dnsThreatDetectorServiceClient.updateDnsThreatDetectorCallable().futureCall(request);
         // Do something.
         DnsThreatDetector response = future.get();
       }
       
    • deleteDnsThreatDetector

      public final void deleteDnsThreatDetector(DnsThreatDetectorName name)
      Deletes a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         DnsThreatDetectorName name =
             DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]");
         dnsThreatDetectorServiceClient.deleteDnsThreatDetector(name);
       }
       
      Parameters:
      name - Required. Name of the DnsThreatDetector resource.
      Throws:
      ApiException - if the remote call fails
    • deleteDnsThreatDetector

      public final void deleteDnsThreatDetector(String name)
      Deletes a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         String name =
             DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]").toString();
         dnsThreatDetectorServiceClient.deleteDnsThreatDetector(name);
       }
       
      Parameters:
      name - Required. Name of the DnsThreatDetector resource.
      Throws:
      ApiException - if the remote call fails
    • deleteDnsThreatDetector

      public final void deleteDnsThreatDetector(DeleteDnsThreatDetectorRequest request)
      Deletes a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         DeleteDnsThreatDetectorRequest request =
             DeleteDnsThreatDetectorRequest.newBuilder()
                 .setName(
                     DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]")
                         .toString())
                 .build();
         dnsThreatDetectorServiceClient.deleteDnsThreatDetector(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • deleteDnsThreatDetectorCallable

      public final UnaryCallable<DeleteDnsThreatDetectorRequest,com.google.protobuf.Empty> deleteDnsThreatDetectorCallable()
      Deletes a single DnsThreatDetector.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         DeleteDnsThreatDetectorRequest request =
             DeleteDnsThreatDetectorRequest.newBuilder()
                 .setName(
                     DnsThreatDetectorName.of("[PROJECT]", "[LOCATION]", "[DNS_THREAT_DETECTOR]")
                         .toString())
                 .build();
         ApiFuture<Empty> future =
             dnsThreatDetectorServiceClient.deleteDnsThreatDetectorCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • listLocations

      Lists information about the supported locations for this service.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         ListLocationsRequest request =
             ListLocationsRequest.newBuilder()
                 .setName("name3373707")
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         for (Location element : dnsThreatDetectorServiceClient.listLocations(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
    • listLocationsPagedCallable

      Lists information about the supported locations for this service.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         ListLocationsRequest request =
             ListLocationsRequest.newBuilder()
                 .setName("name3373707")
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         ApiFuture<Location> future =
             dnsThreatDetectorServiceClient.listLocationsPagedCallable().futureCall(request);
         // Do something.
         for (Location element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listLocationsCallable

      public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> listLocationsCallable()
      Lists information about the supported locations for this service.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         ListLocationsRequest request =
             ListLocationsRequest.newBuilder()
                 .setName("name3373707")
                 .setFilter("filter-1274492040")
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         while (true) {
           ListLocationsResponse response =
               dnsThreatDetectorServiceClient.listLocationsCallable().call(request);
           for (Location element : response.getLocationsList()) {
             // doThingsWith(element);
           }
           String nextPageToken = response.getNextPageToken();
           if (!Strings.isNullOrEmpty(nextPageToken)) {
             request = request.toBuilder().setPageToken(nextPageToken).build();
           } else {
             break;
           }
         }
       }
       
    • getLocation

      public final Location getLocation(GetLocationRequest request)
      Gets information about a location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
         Location response = dnsThreatDetectorServiceClient.getLocation(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getLocationCallable

      public final UnaryCallable<GetLocationRequest,Location> getLocationCallable()
      Gets information about a location.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
         ApiFuture<Location> future =
             dnsThreatDetectorServiceClient.getLocationCallable().futureCall(request);
         // Do something.
         Location response = future.get();
       }
       
    • setIamPolicy

      public final Policy setIamPolicy(SetIamPolicyRequest request)
      Sets the access control policy on the specified resource. Replacesany existing policy.

      Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         SetIamPolicyRequest request =
             SetIamPolicyRequest.newBuilder()
                 .setResource(
                     AuthorizationPolicyName.of("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]")
                         .toString())
                 .setPolicy(Policy.newBuilder().build())
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .build();
         Policy response = dnsThreatDetectorServiceClient.setIamPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • setIamPolicyCallable

      public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()
      Sets the access control policy on the specified resource. Replacesany existing policy.

      Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         SetIamPolicyRequest request =
             SetIamPolicyRequest.newBuilder()
                 .setResource(
                     AuthorizationPolicyName.of("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]")
                         .toString())
                 .setPolicy(Policy.newBuilder().build())
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .build();
         ApiFuture<Policy> future =
             dnsThreatDetectorServiceClient.setIamPolicyCallable().futureCall(request);
         // Do something.
         Policy response = future.get();
       }
       
    • getIamPolicy

      public final Policy getIamPolicy(GetIamPolicyRequest request)
      Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         GetIamPolicyRequest request =
             GetIamPolicyRequest.newBuilder()
                 .setResource(
                     AuthorizationPolicyName.of("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]")
                         .toString())
                 .setOptions(GetPolicyOptions.newBuilder().build())
                 .build();
         Policy response = dnsThreatDetectorServiceClient.getIamPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getIamPolicyCallable

      public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()
      Gets the access control policy for a resource. Returns an empty policyif the resource exists and does not have a policy set.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         GetIamPolicyRequest request =
             GetIamPolicyRequest.newBuilder()
                 .setResource(
                     AuthorizationPolicyName.of("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]")
                         .toString())
                 .setOptions(GetPolicyOptions.newBuilder().build())
                 .build();
         ApiFuture<Policy> future =
             dnsThreatDetectorServiceClient.getIamPolicyCallable().futureCall(request);
         // Do something.
         Policy response = future.get();
       }
       
    • testIamPermissions

      public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)
      Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.

      Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         TestIamPermissionsRequest request =
             TestIamPermissionsRequest.newBuilder()
                 .setResource(
                     AuthorizationPolicyName.of("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]")
                         .toString())
                 .addAllPermissions(new ArrayList<String>())
                 .build();
         TestIamPermissionsResponse response =
             dnsThreatDetectorServiceClient.testIamPermissions(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • testIamPermissionsCallable

      public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()
      Returns permissions that a caller has on the specified resource. If theresource does not exist, this will return an empty set ofpermissions, not a `NOT_FOUND` error.

      Note: This operation is designed to be used for buildingpermission-aware UIs and command-line tools, not for authorizationchecking. This operation may "fail open" without warning.

      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 (DnsThreatDetectorServiceClient dnsThreatDetectorServiceClient =
           DnsThreatDetectorServiceClient.create()) {
         TestIamPermissionsRequest request =
             TestIamPermissionsRequest.newBuilder()
                 .setResource(
                     AuthorizationPolicyName.of("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]")
                         .toString())
                 .addAllPermissions(new ArrayList<String>())
                 .build();
         ApiFuture<TestIamPermissionsResponse> future =
             dnsThreatDetectorServiceClient.testIamPermissionsCallable().futureCall(request);
         // Do something.
         TestIamPermissionsResponse response = future.get();
       }
       
    • 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