@Generated(value="by gapic-generator") @BetaApi public class ContainerAnalysisClient extends Object implements com.google.api.gax.core.BackgroundResource
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:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
IamResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
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:
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:
ContainerAnalysisSettings containerAnalysisSettings =
ContainerAnalysisSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ContainerAnalysisClient containerAnalysisClient =
ContainerAnalysisClient.create(containerAnalysisSettings);
To customize the endpoint:
ContainerAnalysisSettings containerAnalysisSettings =
ContainerAnalysisSettings.newBuilder().setEndpoint(myEndpoint).build();
ContainerAnalysisClient containerAnalysisClient =
ContainerAnalysisClient.create(containerAnalysisSettings);
Modifier | Constructor and Description |
---|---|
protected |
ContainerAnalysisClient(ContainerAnalysisSettings settings)
Constructs an instance of ContainerAnalysisClient, using the given settings.
|
protected |
ContainerAnalysisClient(ContainerAnalysisStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ContainerAnalysisClient |
create()
Constructs an instance of ContainerAnalysisClient with default settings.
|
static ContainerAnalysisClient |
create(ContainerAnalysisSettings settings)
Constructs an instance of ContainerAnalysisClient, using the given settings.
|
static ContainerAnalysisClient |
create(ContainerAnalysisStub stub)
Constructs an instance of ContainerAnalysisClient, using the given stub for making calls.
|
GrafeasClient |
getGrafeasClient()
Returns a new GrafeasClient with the same configured settings.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a note or an occurrence resource.
|
com.google.iam.v1.Policy |
getIamPolicy(IamResourceName resource)
Gets the access control policy for a note or an occurrence resource.
|
com.google.iam.v1.Policy |
getIamPolicy(String resource)
Gets the access control policy for a note or an occurrence resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the access control policy for a note or an occurrence resource.
|
ContainerAnalysisSettings |
getSettings() |
ContainerAnalysisStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
com.google.iam.v1.Policy |
setIamPolicy(IamResourceName resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on the specified note or occurrence.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on the specified note or occurrence.
|
com.google.iam.v1.Policy |
setIamPolicy(String resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on the specified note or occurrence.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the access control policy on the specified note or occurrence.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(IamResourceName resource,
List<String> permissions)
Returns the permissions that a caller has on the specified note or occurrence.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(String resource,
List<String> permissions)
Returns the permissions that a caller has on the specified note or occurrence.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns the permissions that a caller has on the specified note or occurrence.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns the permissions that a caller has on the specified note or occurrence.
|
protected ContainerAnalysisClient(ContainerAnalysisSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ContainerAnalysisClient(ContainerAnalysisStub stub)
public GrafeasClient getGrafeasClient() throws IOException
IOException
public static final ContainerAnalysisClient create() throws IOException
IOException
public static final ContainerAnalysisClient create(ContainerAnalysisSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ContainerAnalysisClient create(ContainerAnalysisStub stub)
public final ContainerAnalysisSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ContainerAnalysisStub getStub()
public final com.google.iam.v1.Policy setIamPolicy(IamResourceName resource, com.google.iam.v1.Policy policy)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
IamResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
Policy policy = Policy.newBuilder().build();
Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
}
resource
- REQUIRED: The resource for which the policy is being specified. See the
operation documentation for the appropriate value for this field.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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(String resource, com.google.iam.v1.Policy policy)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
IamResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
Policy policy = Policy.newBuilder().build();
Policy response = containerAnalysisClient.setIamPolicy(resource.toString(), policy);
}
resource
- REQUIRED: The resource for which the policy is being specified. See the
operation documentation for the appropriate value for this field.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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
ResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
Policy policy = Policy.newBuilder().build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.setPolicy(policy)
.build();
Policy response = containerAnalysisClient.setIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
ResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
Policy policy = Policy.newBuilder().build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.setPolicy(policy)
.build();
ApiFuture<Policy> future = containerAnalysisClient.setIamPolicyCallable().futureCall(request);
// Do something
Policy response = future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(IamResourceName resource)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
IamResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
Policy response = containerAnalysisClient.getIamPolicy(resource);
}
resource
- REQUIRED: The resource for which the policy is being requested. See the
operation documentation for the appropriate value for this field.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(String resource)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
IamResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
Policy response = containerAnalysisClient.getIamPolicy(resource.toString());
}
resource
- REQUIRED: The resource for which the policy is being requested. See the
operation documentation for the appropriate value for this field.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
ResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.build();
Policy response = containerAnalysisClient.getIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
ResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.build();
ApiFuture<Policy> future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
// Do something
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(IamResourceName resource, List<String> permissions)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
IamResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(resource, permissions);
}
resource
- REQUIRED: The resource for which the policy detail is being requested. See the
operation documentation for the appropriate value for this field.permissions
- 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](https://cloud.google.com/iam/docs/overview#permissions).com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
IamResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(resource.toString(), permissions);
}
resource
- REQUIRED: The resource for which the policy detail is being requested. See the
operation documentation for the appropriate value for this field.permissions
- 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](https://cloud.google.com/iam/docs/overview#permissions).com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
ResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
.setResource(resource.toString())
.addAllPermissions(permissions)
.build();
TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
Sample code:
try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
ResourceName resource = NoteName.of("[PROJECT]", "[NOTE]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
.setResource(resource.toString())
.addAllPermissions(permissions)
.build();
ApiFuture<TestIamPermissionsResponse> future = containerAnalysisClient.testIamPermissionsCallable().futureCall(request);
// Do something
TestIamPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.