Class ContainerAnalysisClient (2.4.2)

public class ContainerAnalysisClient implements BackgroundResource

Service Description: Retrieves analysis results of Cloud components such as Docker container images. The Container Analysis API is an implementation of the Grafeas API.

Analysis results are stored as a series of occurrences. An Occurrence contains information about a specific analysis instance on a resource. An occurrence refers to a Note. A note contains details describing the analysis and is generally stored in a separate project, called a Provider. Multiple occurrences can refer to the same note.

For example, an SSL vulnerability could affect multiple images. In this case, there would be one note for the vulnerability and an occurrence for each image with the vulnerability referring to that note.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   ResourceName resource =
       new ResourceName() {
         {@literal @}Override
         public Map<String, String> getFieldValuesMap() {
           Map<String, String> fieldValuesMap = new HashMap<>();
           fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
           return fieldValuesMap;
         }

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

         {@literal @}Override
         public String toString() {
           return "projects/project-8432/notes/note-8432";
         }
       };
   Policy policy = Policy.newBuilder().build();
   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
 }
 

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

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ContainerAnalysisSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 ContainerAnalysisSettings containerAnalysisSettings =
     ContainerAnalysisSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ContainerAnalysisClient containerAnalysisClient =
     ContainerAnalysisClient.create(containerAnalysisSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 ContainerAnalysisSettings containerAnalysisSettings =
     ContainerAnalysisSettings.newBuilder().setEndpoint(myEndpoint).build();
 ContainerAnalysisClient containerAnalysisClient =
     ContainerAnalysisClient.create(containerAnalysisSettings);
 

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


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 ContainerAnalysisSettings containerAnalysisSettings =
     ContainerAnalysisSettings.newBuilder()
         .setTransportChannelProvider(
             ContainerAnalysisSettings.defaultHttpJsonTransportProviderBuilder().build())
         .build();
 ContainerAnalysisClient containerAnalysisClient =
     ContainerAnalysisClient.create(containerAnalysisSettings);
 

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

Inheritance

java.lang.Object > ContainerAnalysisClient

Implements

BackgroundResource

Static Methods

create()

public static final ContainerAnalysisClient create()

Constructs an instance of ContainerAnalysisClient with default settings.

Returns
TypeDescription
ContainerAnalysisClient
Exceptions
TypeDescription
IOException

create(ContainerAnalysisSettings settings)

public static final ContainerAnalysisClient create(ContainerAnalysisSettings settings)

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

Parameter
NameDescription
settingsContainerAnalysisSettings
Returns
TypeDescription
ContainerAnalysisClient
Exceptions
TypeDescription
IOException

create(ContainerAnalysisStub stub)

public static final ContainerAnalysisClient create(ContainerAnalysisStub stub)

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

Parameter
NameDescription
stubContainerAnalysisStub
Returns
TypeDescription
ContainerAnalysisClient

Constructors

ContainerAnalysisClient(ContainerAnalysisSettings settings)

protected ContainerAnalysisClient(ContainerAnalysisSettings settings)

Constructs an instance of ContainerAnalysisClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
NameDescription
settingsContainerAnalysisSettings

ContainerAnalysisClient(ContainerAnalysisStub stub)

protected ContainerAnalysisClient(ContainerAnalysisStub stub)
Parameter
NameDescription
stubContainerAnalysisStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

getGrafeasClient()

public GrafeasClient getGrafeasClient()

Returns a new GrafeasClient with the same configured settings.

Returns
TypeDescription
io.grafeas.v1.GrafeasClient
Exceptions
TypeDescription
IOException

getIamPolicy(ResourceName resource)

public final Policy getIamPolicy(ResourceName resource)

Gets the access control policy for a note or an occurrence resource. Requires containeranalysis.notes.setIamPolicy or containeranalysis.occurrences.setIamPolicy permission if the resource is a note or occurrence, respectively.

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   ResourceName resource =
       new ResourceName() {
         {@literal @}Override
         public Map<String, String> getFieldValuesMap() {
           Map<String, String> fieldValuesMap = new HashMap<>();
           fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
           return fieldValuesMap;
         }

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

         {@literal @}Override
         public String toString() {
           return "projects/project-8432/notes/note-8432";
         }
       };
   Policy response = containerAnalysisClient.getIamPolicy(resource);
 }
 
Parameter
NameDescription
resourcecom.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicy(GetIamPolicyRequest request)

public final Policy getIamPolicy(GetIamPolicyRequest request)

Gets the access control policy for a note or an occurrence resource. Requires containeranalysis.notes.setIamPolicy or containeranalysis.occurrences.setIamPolicy permission if the resource is a note or occurrence, respectively.

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource("GetIamPolicyRequest-1527610370".toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   Policy response = containerAnalysisClient.getIamPolicy(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.GetIamPolicyRequest

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

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicy(String resource)

public final Policy getIamPolicy(String resource)

Gets the access control policy for a note or an occurrence resource. Requires containeranalysis.notes.setIamPolicy or containeranalysis.occurrences.setIamPolicy permission if the resource is a note or occurrence, respectively.

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   String resource = ProjectName.of("[PROJECT]").toString();
   Policy response = containerAnalysisClient.getIamPolicy(resource);
 }
 
Parameter
NameDescription
resourceString

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicyCallable()

public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()

Gets the access control policy for a note or an occurrence resource. Requires containeranalysis.notes.setIamPolicy or containeranalysis.occurrences.setIamPolicy permission if the resource is a note or occurrence, respectively.

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource("GetIamPolicyRequest-1527610370".toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   ApiFuture<Policy> future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>

getSettings()

public final ContainerAnalysisSettings getSettings()
Returns
TypeDescription
ContainerAnalysisSettings

getStub()

public ContainerAnalysisStub getStub()
Returns
TypeDescription
ContainerAnalysisStub

getVulnerabilityOccurrencesSummary(GetVulnerabilityOccurrencesSummaryRequest request)

public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(GetVulnerabilityOccurrencesSummaryRequest request)

Gets a summary of the number and severity of occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   GetVulnerabilityOccurrencesSummaryRequest request =
       GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setFilter("filter-1274492040")
           .build();
   VulnerabilityOccurrencesSummary response =
       containerAnalysisClient.getVulnerabilityOccurrencesSummary(request);
 }
 
Parameter
NameDescription
requestGetVulnerabilityOccurrencesSummaryRequest

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

Returns
TypeDescription
VulnerabilityOccurrencesSummary

getVulnerabilityOccurrencesSummary(ProjectName parent, String filter)

public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(ProjectName parent, String filter)

Gets a summary of the number and severity of occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   String filter = "filter-1274492040";
   VulnerabilityOccurrencesSummary response =
       containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
 }
 
Parameters
NameDescription
parentProjectName

Required. The name of the project to get a vulnerability summary for in the form of projects/[PROJECT_ID].

filterString

The filter expression.

Returns
TypeDescription
VulnerabilityOccurrencesSummary

getVulnerabilityOccurrencesSummary(String parent, String filter)

public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(String parent, String filter)

Gets a summary of the number and severity of occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   String filter = "filter-1274492040";
   VulnerabilityOccurrencesSummary response =
       containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
 }
 
Parameters
NameDescription
parentString

Required. The name of the project to get a vulnerability summary for in the form of projects/[PROJECT_ID].

filterString

The filter expression.

Returns
TypeDescription
VulnerabilityOccurrencesSummary

getVulnerabilityOccurrencesSummaryCallable()

public final UnaryCallable<GetVulnerabilityOccurrencesSummaryRequest,VulnerabilityOccurrencesSummary> getVulnerabilityOccurrencesSummaryCallable()

Gets a summary of the number and severity of occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   GetVulnerabilityOccurrencesSummaryRequest request =
       GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<VulnerabilityOccurrencesSummary> future =
       containerAnalysisClient.getVulnerabilityOccurrencesSummaryCallable().futureCall(request);
   // Do something.
   VulnerabilityOccurrencesSummary response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetVulnerabilityOccurrencesSummaryRequest,VulnerabilityOccurrencesSummary>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

setIamPolicy(ResourceName resource, Policy policy)

public final Policy setIamPolicy(ResourceName resource, Policy policy)

Sets the access control policy on the specified note or occurrence. Requires containeranalysis.notes.setIamPolicy or containeranalysis.occurrences.setIamPolicy permission if the resource is a note or an occurrence, respectively.

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   ResourceName resource =
       new ResourceName() {
         {@literal @}Override
         public Map<String, String> getFieldValuesMap() {
           Map<String, String> fieldValuesMap = new HashMap<>();
           fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
           return fieldValuesMap;
         }

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

         {@literal @}Override
         public String toString() {
           return "projects/project-8432/notes/note-8432";
         }
       };
   Policy policy = Policy.newBuilder().build();
   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
 }
 
Parameters
NameDescription
resourcecom.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policycom.google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicy(SetIamPolicyRequest request)

public final Policy setIamPolicy(SetIamPolicyRequest request)

Sets the access control policy on the specified note or occurrence. Requires containeranalysis.notes.setIamPolicy or containeranalysis.occurrences.setIamPolicy permission if the resource is a note or an occurrence, respectively.

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource("SetIamPolicyRequest1223629066".toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Policy response = containerAnalysisClient.setIamPolicy(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.SetIamPolicyRequest

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

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicy(String resource, Policy policy)

public final Policy setIamPolicy(String resource, Policy policy)

Sets the access control policy on the specified note or occurrence. Requires containeranalysis.notes.setIamPolicy or containeranalysis.occurrences.setIamPolicy permission if the resource is a note or an occurrence, respectively.

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   String resource = ProjectName.of("[PROJECT]").toString();
   Policy policy = Policy.newBuilder().build();
   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
 }
 
Parameters
NameDescription
resourceString

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policycom.google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicyCallable()

public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()

Sets the access control policy on the specified note or occurrence. Requires containeranalysis.notes.setIamPolicy or containeranalysis.occurrences.setIamPolicy permission if the resource is a note or an occurrence, respectively.

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource("SetIamPolicyRequest1223629066".toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Policy> future = containerAnalysisClient.setIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

testIamPermissions(ResourceName resource, List<String> permissions)

public final TestIamPermissionsResponse testIamPermissions(ResourceName resource, List<String> permissions)

Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, containeranalysis.notes.list).

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   ResourceName resource =
       new ResourceName() {
         {@literal @}Override
         public Map<String, String> getFieldValuesMap() {
           Map<String, String> fieldValuesMap = new HashMap<>();
           fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
           return fieldValuesMap;
         }

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

         {@literal @}Override
         public String toString() {
           return "projects/project-8432/notes/note-8432";
         }
       };
   List<String> permissions = new ArrayList<>();
   TestIamPermissionsResponse response =
       containerAnalysisClient.testIamPermissions(resource, permissions);
 }
 
Parameters
NameDescription
resourcecom.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissionsList<String>

The set of permissions to check for the resource. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see IAM Overview.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissions(TestIamPermissionsRequest request)

public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)

Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, containeranalysis.notes.list).

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource("TestIamPermissionsRequest942398222".toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.TestIamPermissionsRequest

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

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissions(String resource, List<String> permissions)

public final TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)

Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, containeranalysis.notes.list).

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   String resource = ProjectName.of("[PROJECT]").toString();
   List<String> permissions = new ArrayList<>();
   TestIamPermissionsResponse response =
       containerAnalysisClient.testIamPermissions(resource, permissions);
 }
 
Parameters
NameDescription
resourceString

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissionsList<String>

The set of permissions to check for the resource. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see IAM Overview.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissionsCallable()

public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()

Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, containeranalysis.notes.list).

The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] for notes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] for occurrences.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource("TestIamPermissionsRequest942398222".toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   ApiFuture<TestIamPermissionsResponse> future =
       containerAnalysisClient.testIamPermissionsCallable().futureCall(request);
   // Do something.
   TestIamPermissionsResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>