Class ContainerAnalysisClient (2.57.0)
Stay organized with collections
Save and categorize content based on your preferences.
- 2.81.0 (latest)
- 2.79.0
- 2.77.0
- 2.76.0
- 2.75.0
- 2.74.0
- 2.73.0
- 2.71.0
- 2.69.0
- 2.68.0
- 2.65.0
- 2.64.0
- 2.63.0
- 2.61.0
- 2.60.0
- 2.59.0
- 2.58.0
- 2.57.0
- 2.56.0
- 2.55.0
- 2.54.0
- 2.53.0
- 2.52.0
- 2.50.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.40.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.28.0
- 2.25.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.10
- 2.3.1
- 2.2.16
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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
ResourceNameresource=
newResourceName(){
{@literal@}Override
publicMap<String,String>getFieldValuesMap(){
Map<String,String>fieldValuesMap=newHashMap<>();
fieldValuesMap.put("resource","projects/project-8432/notes/note-8432");
returnfieldValuesMap;
}
{@literal@}Override
publicStringgetFieldValue(StringfieldName){
returngetFieldValuesMap().get(fieldName);
}
{@literal@}Override
publicStringtoString(){
return"projects/project-8432/notes/note-8432";
}
};
Policypolicy=Policy.newBuilder().build();
Policyresponse=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().
| Method | Description | Method Variants |
|---|---|---|
SetIamPolicy |
Sets the access control policy on the specified note or occurrence. Requires The resource takes the format |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIamPolicy |
Gets the access control policy for a note or an occurrence resource. Requires The resource takes the format |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, The resource takes the format |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetVulnerabilityOccurrencesSummary |
Gets a summary of the number and severity of occurrences. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 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
ContainerAnalysisSettingscontainerAnalysisSettings=
ContainerAnalysisSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ContainerAnalysisClientcontainerAnalysisClient=
ContainerAnalysisClient.create(containerAnalysisSettings);
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
ContainerAnalysisSettingscontainerAnalysisSettings=
ContainerAnalysisSettings.newBuilder().setEndpoint(myEndpoint).build();
ContainerAnalysisClientcontainerAnalysisClient=
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 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
ContainerAnalysisSettingscontainerAnalysisSettings=
ContainerAnalysisSettings.newHttpJsonBuilder().build();
ContainerAnalysisClientcontainerAnalysisClient=
ContainerAnalysisClient.create(containerAnalysisSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
publicstaticfinalContainerAnalysisClientcreate()Constructs an instance of ContainerAnalysisClient with default settings.
| Returns | |
|---|---|
| Type | Description |
ContainerAnalysisClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(ContainerAnalysisSettings settings)
publicstaticfinalContainerAnalysisClientcreate(ContainerAnalysisSettingssettings)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 | |
|---|---|
| Name | Description |
settings |
ContainerAnalysisSettings |
| Returns | |
|---|---|
| Type | Description |
ContainerAnalysisClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(ContainerAnalysisStub stub)
publicstaticfinalContainerAnalysisClientcreate(ContainerAnalysisStubstub)Constructs an instance of ContainerAnalysisClient, using the given stub for making calls. This is for advanced usage - prefer using create(ContainerAnalysisSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
ContainerAnalysisStub |
| Returns | |
|---|---|
| Type | Description |
ContainerAnalysisClient |
|
Constructors
ContainerAnalysisClient(ContainerAnalysisSettings settings)
protectedContainerAnalysisClient(ContainerAnalysisSettingssettings)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 | |
|---|---|
| Name | Description |
settings |
ContainerAnalysisSettings |
ContainerAnalysisClient(ContainerAnalysisStub stub)
protectedContainerAnalysisClient(ContainerAnalysisStubstub)| Parameter | |
|---|---|
| Name | Description |
stub |
ContainerAnalysisStub |
Methods
awaitTermination(long duration, TimeUnit unit)
publicbooleanawaitTermination(longduration,TimeUnitunit)| Parameters | |
|---|---|
| Name | Description |
duration |
long |
unit |
TimeUnit |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
InterruptedException |
|
close()
publicfinalvoidclose()getGrafeasClient()
publicGrafeasClientgetGrafeasClient()Returns a new GrafeasClient with the same configured settings.
| Returns | |
|---|---|
| Type | Description |
io.grafeas.v1.GrafeasClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
getIamPolicy(ResourceName resource)
publicfinalPolicygetIamPolicy(ResourceNameresource)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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
ResourceNameresource=
newResourceName(){
{@literal@}Override
publicMap<String,String>getFieldValuesMap(){
Map<String,String>fieldValuesMap=newHashMap<>();
fieldValuesMap.put("resource","projects/project-8432/notes/note-8432");
returnfieldValuesMap;
}
{@literal@}Override
publicStringgetFieldValue(StringfieldName){
returngetFieldValuesMap().get(fieldName);
}
{@literal@}Override
publicStringtoString(){
return"projects/project-8432/notes/note-8432";
}
};
Policyresponse=containerAnalysisClient.getIamPolicy(resource);
}
| Parameter | |
|---|---|
| Name | Description |
resource |
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
getIamPolicy(GetIamPolicyRequest request)
publicfinalPolicygetIamPolicy(GetIamPolicyRequestrequest)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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
GetIamPolicyRequestrequest=
GetIamPolicyRequest.newBuilder()
.setResource("GetIamPolicyRequest-1527610370".toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policyresponse=containerAnalysisClient.getIamPolicy(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.iam.v1.GetIamPolicyRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
getIamPolicy(String resource)
publicfinalPolicygetIamPolicy(Stringresource)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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
Stringresource=ProjectName.of("[PROJECT]").toString();
Policyresponse=containerAnalysisClient.getIamPolicy(resource);
}
| Parameter | |
|---|---|
| Name | Description |
resource |
String REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
getIamPolicyCallable()
publicfinalUnaryCallable<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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
GetIamPolicyRequestrequest=
GetIamPolicyRequest.newBuilder()
.setResource("GetIamPolicyRequest-1527610370".toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy>future=containerAnalysisClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policyresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
|
getSettings()
publicfinalContainerAnalysisSettingsgetSettings()| Returns | |
|---|---|
| Type | Description |
ContainerAnalysisSettings |
|
getStub()
publicContainerAnalysisStubgetStub()| Returns | |
|---|---|
| Type | Description |
ContainerAnalysisStub |
|
getVulnerabilityOccurrencesSummary(GetVulnerabilityOccurrencesSummaryRequest request)
publicfinalVulnerabilityOccurrencesSummarygetVulnerabilityOccurrencesSummary(GetVulnerabilityOccurrencesSummaryRequestrequest)Gets a summary of the number and severity of occurrences.
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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
GetVulnerabilityOccurrencesSummaryRequestrequest=
GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setFilter("filter-1274492040")
.build();
VulnerabilityOccurrencesSummaryresponse=
containerAnalysisClient.getVulnerabilityOccurrencesSummary(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetVulnerabilityOccurrencesSummaryRequest The request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
VulnerabilityOccurrencesSummary |
|
getVulnerabilityOccurrencesSummary(ProjectName parent, String filter)
publicfinalVulnerabilityOccurrencesSummarygetVulnerabilityOccurrencesSummary(ProjectNameparent,Stringfilter)Gets a summary of the number and severity of occurrences.
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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
ProjectNameparent=ProjectName.of("[PROJECT]");
Stringfilter="filter-1274492040";
VulnerabilityOccurrencesSummaryresponse=
containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent,filter);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
ProjectName Required. The name of the project to get a vulnerability summary for in the form
of |
filter |
String The filter expression. |
| Returns | |
|---|---|
| Type | Description |
VulnerabilityOccurrencesSummary |
|
getVulnerabilityOccurrencesSummary(String parent, String filter)
publicfinalVulnerabilityOccurrencesSummarygetVulnerabilityOccurrencesSummary(Stringparent,Stringfilter)Gets a summary of the number and severity of occurrences.
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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
Stringparent=ProjectName.of("[PROJECT]").toString();
Stringfilter="filter-1274492040";
VulnerabilityOccurrencesSummaryresponse=
containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent,filter);
}
| Parameters | |
|---|---|
| Name | Description |
parent |
String Required. The name of the project to get a vulnerability summary for in the form
of |
filter |
String The filter expression. |
| Returns | |
|---|---|
| Type | Description |
VulnerabilityOccurrencesSummary |
|
getVulnerabilityOccurrencesSummaryCallable()
publicfinalUnaryCallable<GetVulnerabilityOccurrencesSummaryRequest,VulnerabilityOccurrencesSummary>getVulnerabilityOccurrencesSummaryCallable()Gets a summary of the number and severity of occurrences.
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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
GetVulnerabilityOccurrencesSummaryRequestrequest=
GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setFilter("filter-1274492040")
.build();
ApiFuture<VulnerabilityOccurrencesSummary>future=
containerAnalysisClient.getVulnerabilityOccurrencesSummaryCallable().futureCall(request);
// Do something.
VulnerabilityOccurrencesSummaryresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetVulnerabilityOccurrencesSummaryRequest,VulnerabilityOccurrencesSummary> |
|
isShutdown()
publicbooleanisShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
publicbooleanisTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
setIamPolicy(ResourceName resource, Policy policy)
publicfinalPolicysetIamPolicy(ResourceNameresource,Policypolicy)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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
ResourceNameresource=
newResourceName(){
{@literal@}Override
publicMap<String,String>getFieldValuesMap(){
Map<String,String>fieldValuesMap=newHashMap<>();
fieldValuesMap.put("resource","projects/project-8432/notes/note-8432");
returnfieldValuesMap;
}
{@literal@}Override
publicStringgetFieldValue(StringfieldName){
returngetFieldValuesMap().get(fieldName);
}
{@literal@}Override
publicStringtoString(){
return"projects/project-8432/notes/note-8432";
}
};
Policypolicy=Policy.newBuilder().build();
Policyresponse=containerAnalysisClient.setIamPolicy(resource,policy);
}
| Parameters | |
|---|---|
| Name | Description |
resource |
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy |
com.google.iam.v1.PolicyREQUIRED: The complete policy to be applied to the |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
setIamPolicy(SetIamPolicyRequest request)
publicfinalPolicysetIamPolicy(SetIamPolicyRequestrequest)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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
SetIamPolicyRequestrequest=
SetIamPolicyRequest.newBuilder()
.setResource("SetIamPolicyRequest1223629066".toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policyresponse=containerAnalysisClient.setIamPolicy(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.iam.v1.SetIamPolicyRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
setIamPolicy(String resource, Policy policy)
publicfinalPolicysetIamPolicy(Stringresource,Policypolicy)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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
Stringresource=ProjectName.of("[PROJECT]").toString();
Policypolicy=Policy.newBuilder().build();
Policyresponse=containerAnalysisClient.setIamPolicy(resource,policy);
}
| Parameters | |
|---|---|
| Name | Description |
resource |
String REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy |
com.google.iam.v1.PolicyREQUIRED: The complete policy to be applied to the |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.Policy |
|
setIamPolicyCallable()
publicfinalUnaryCallable<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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
SetIamPolicyRequestrequest=
SetIamPolicyRequest.newBuilder()
.setResource("SetIamPolicyRequest1223629066".toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy>future=containerAnalysisClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policyresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
|
shutdown()
publicvoidshutdown()shutdownNow()
publicvoidshutdownNow()testIamPermissions(ResourceName resource, List<String> permissions)
publicfinalTestIamPermissionsResponsetestIamPermissions(ResourceNameresource,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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
ResourceNameresource=
newResourceName(){
{@literal@}Override
publicMap<String,String>getFieldValuesMap(){
Map<String,String>fieldValuesMap=newHashMap<>();
fieldValuesMap.put("resource","projects/project-8432/notes/note-8432");
returnfieldValuesMap;
}
{@literal@}Override
publicStringgetFieldValue(StringfieldName){
returngetFieldValuesMap().get(fieldName);
}
{@literal@}Override
publicStringtoString(){
return"projects/project-8432/notes/note-8432";
}
};
List<String>permissions=newArrayList<>();
TestIamPermissionsResponseresponse=
containerAnalysisClient.testIamPermissions(resource,permissions);
}
| Parameters | |
|---|---|
| Name | Description |
resource |
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions |
List<String>The set of permissions to check for the |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
|
testIamPermissions(TestIamPermissionsRequest request)
publicfinalTestIamPermissionsResponsetestIamPermissions(TestIamPermissionsRequestrequest)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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
TestIamPermissionsRequestrequest=
TestIamPermissionsRequest.newBuilder()
.setResource("TestIamPermissionsRequest942398222".toString())
.addAllPermissions(newArrayList<String>())
.build();
TestIamPermissionsResponseresponse=containerAnalysisClient.testIamPermissions(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
com.google.iam.v1.TestIamPermissionsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
|
testIamPermissions(String resource, List<String> permissions)
publicfinalTestIamPermissionsResponsetestIamPermissions(Stringresource,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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
Stringresource=ProjectName.of("[PROJECT]").toString();
List<String>permissions=newArrayList<>();
TestIamPermissionsResponseresponse=
containerAnalysisClient.testIamPermissions(resource,permissions);
}
| Parameters | |
|---|---|
| Name | Description |
resource |
String REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions |
List<String>The set of permissions to check for the |
| Returns | |
|---|---|
| Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
|
testIamPermissionsCallable()
publicfinalUnaryCallable<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 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(ContainerAnalysisClientcontainerAnalysisClient=ContainerAnalysisClient.create()){
TestIamPermissionsRequestrequest=
TestIamPermissionsRequest.newBuilder()
.setResource("TestIamPermissionsRequest942398222".toString())
.addAllPermissions(newArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse>future=
containerAnalysisClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponseresponse=future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
|