Class ImagesClient
- java.lang.Object
-
- com.google.cloud.compute.v1.ImagesClient
-
- All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource
,AutoCloseable
@Generated("by gapic-generator-java") public class ImagesClient extends Object implements com.google.api.gax.core.BackgroundResource
Service Description: The Images API.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String image = "image100313435"; Image response = imagesClient.get(project, image); }
Note: close() needs to be called on the ImagesClient 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:
- 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.
- 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.
- 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 ImagesSettings 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 ImagesSettings imagesSettings = ImagesSettings.newBuilder() .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) .build(); ImagesClient imagesClient = ImagesClient.create(imagesSettings);
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 ImagesSettings imagesSettings = ImagesSettings.newBuilder().setEndpoint(myEndpoint).build(); ImagesClient imagesClient = ImagesClient.create(imagesSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImagesClient.ListFixedSizeCollection
static class
ImagesClient.ListPage
static class
ImagesClient.ListPagedResponse
-
Constructor Summary
Constructors Modifier Constructor Description protected
ImagesClient(ImagesSettings settings)
Constructs an instance of ImagesClient, using the given settings.protected
ImagesClient(ImagesStub stub)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(long duration, TimeUnit unit)
void
close()
static ImagesClient
create()
Constructs an instance of ImagesClient with default settings.static ImagesClient
create(ImagesSettings settings)
Constructs an instance of ImagesClient, using the given settings.static ImagesClient
create(ImagesStub stub)
Constructs an instance of ImagesClient, using the given stub for making calls.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
deleteAsync(DeleteImageRequest request)
Deletes the specified image.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
deleteAsync(String project, String image)
Deletes the specified image.com.google.api.gax.rpc.UnaryCallable<DeleteImageRequest,Operation>
deleteCallable()
Deletes the specified image.com.google.api.gax.rpc.OperationCallable<DeleteImageRequest,Operation,Operation>
deleteOperationCallable()
Deletes the specified image.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
deprecateAsync(DeprecateImageRequest request)
Sets the deprecation status of an image.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
deprecateAsync(String project, String image, DeprecationStatus deprecationStatusResource)
Sets the deprecation status of an image.com.google.api.gax.rpc.UnaryCallable<DeprecateImageRequest,Operation>
deprecateCallable()
Sets the deprecation status of an image.com.google.api.gax.rpc.OperationCallable<DeprecateImageRequest,Operation,Operation>
deprecateOperationCallable()
Sets the deprecation status of an image.Image
get(GetImageRequest request)
Returns the specified image.Image
get(String project, String image)
Returns the specified image.com.google.api.gax.rpc.UnaryCallable<GetImageRequest,Image>
getCallable()
Returns the specified image.Image
getFromFamily(GetFromFamilyImageRequest request)
Returns the latest image that is part of an image family and is not deprecated.Image
getFromFamily(String project, String family)
Returns the latest image that is part of an image family and is not deprecated.com.google.api.gax.rpc.UnaryCallable<GetFromFamilyImageRequest,Image>
getFromFamilyCallable()
Returns the latest image that is part of an image family and is not deprecated.Policy
getIamPolicy(GetIamPolicyImageRequest request)
Gets the access control policy for a resource.Policy
getIamPolicy(String project, String resource)
Gets the access control policy for a resource.com.google.api.gax.rpc.UnaryCallable<GetIamPolicyImageRequest,Policy>
getIamPolicyCallable()
Gets the access control policy for a resource.ImagesSettings
getSettings()
ImagesStub
getStub()
com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
insertAsync(InsertImageRequest request)
Creates an image in the specified project using the data included in the request.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
insertAsync(String project, Image imageResource)
Creates an image in the specified project using the data included in the request.com.google.api.gax.rpc.UnaryCallable<InsertImageRequest,Operation>
insertCallable()
Creates an image in the specified project using the data included in the request.com.google.api.gax.rpc.OperationCallable<InsertImageRequest,Operation,Operation>
insertOperationCallable()
Creates an image in the specified project using the data included in the request.boolean
isShutdown()
boolean
isTerminated()
ImagesClient.ListPagedResponse
list(ListImagesRequest request)
Retrieves the list of custom images available to the specified project.ImagesClient.ListPagedResponse
list(String project)
Retrieves the list of custom images available to the specified project.com.google.api.gax.rpc.UnaryCallable<ListImagesRequest,ImageList>
listCallable()
Retrieves the list of custom images available to the specified project.com.google.api.gax.rpc.UnaryCallable<ListImagesRequest,ImagesClient.ListPagedResponse>
listPagedCallable()
Retrieves the list of custom images available to the specified project.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
patchAsync(PatchImageRequest request)
Patches the specified image with the data included in the request.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
patchAsync(String project, String image, Image imageResource)
Patches the specified image with the data included in the request.com.google.api.gax.rpc.UnaryCallable<PatchImageRequest,Operation>
patchCallable()
Patches the specified image with the data included in the request.com.google.api.gax.rpc.OperationCallable<PatchImageRequest,Operation,Operation>
patchOperationCallable()
Patches the specified image with the data included in the request.Policy
setIamPolicy(SetIamPolicyImageRequest request)
Sets the access control policy on the specified resource.Policy
setIamPolicy(String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sets the access control policy on the specified resource.com.google.api.gax.rpc.UnaryCallable<SetIamPolicyImageRequest,Policy>
setIamPolicyCallable()
Sets the access control policy on the specified resource.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
setLabelsAsync(SetLabelsImageRequest request)
Sets the labels on an image.com.google.api.gax.longrunning.OperationFuture<Operation,Operation>
setLabelsAsync(String project, String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)
Sets the labels on an image.com.google.api.gax.rpc.UnaryCallable<SetLabelsImageRequest,Operation>
setLabelsCallable()
Sets the labels on an image.com.google.api.gax.rpc.OperationCallable<SetLabelsImageRequest,Operation,Operation>
setLabelsOperationCallable()
Sets the labels on an image.void
shutdown()
void
shutdownNow()
TestPermissionsResponse
testIamPermissions(TestIamPermissionsImageRequest request)
Returns permissions that a caller has on the specified resource.TestPermissionsResponse
testIamPermissions(String project, String resource, TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsImageRequest,TestPermissionsResponse>
testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.
-
-
-
Constructor Detail
-
ImagesClient
protected ImagesClient(ImagesSettings settings) throws IOException
Constructs an instance of ImagesClient, 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
-
ImagesClient
protected ImagesClient(ImagesStub stub)
-
-
Method Detail
-
create
public static final ImagesClient create() throws IOException
Constructs an instance of ImagesClient with default settings.- Throws:
IOException
-
create
public static final ImagesClient create(ImagesSettings settings) throws IOException
Constructs an instance of ImagesClient, 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
public static final ImagesClient create(ImagesStub stub)
Constructs an instance of ImagesClient, using the given stub for making calls. This is for advanced usage - prefer using create(ImagesSettings).
-
getSettings
public final ImagesSettings getSettings()
-
getStub
public ImagesStub getStub()
-
deleteAsync
public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> deleteAsync(String project, String image)
Deletes the specified image.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String image = "image100313435"; Operation response = imagesClient.deleteAsync(project, image).get(); }
- Parameters:
project
- Project ID for this request.image
- Name of the image resource to delete.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
deleteAsync
@BetaApi("The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> deleteAsync(DeleteImageRequest request)
Deletes the specified image.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 (ImagesClient imagesClient = ImagesClient.create()) { DeleteImageRequest request = DeleteImageRequest.newBuilder() .setImage("image100313435") .setProject("project-309310695") .setRequestId("requestId693933066") .build(); Operation response = imagesClient.deleteAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
deleteOperationCallable
public final com.google.api.gax.rpc.OperationCallable<DeleteImageRequest,Operation,Operation> deleteOperationCallable()
Deletes the specified image.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 (ImagesClient imagesClient = ImagesClient.create()) { DeleteImageRequest request = DeleteImageRequest.newBuilder() .setImage("image100313435") .setProject("project-309310695") .setRequestId("requestId693933066") .build(); OperationFuture<Operation, Operation> future = imagesClient.deleteOperationCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
deleteCallable
public final com.google.api.gax.rpc.UnaryCallable<DeleteImageRequest,Operation> deleteCallable()
Deletes the specified image.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 (ImagesClient imagesClient = ImagesClient.create()) { DeleteImageRequest request = DeleteImageRequest.newBuilder() .setImage("image100313435") .setProject("project-309310695") .setRequestId("requestId693933066") .build(); ApiFuture<Operation> future = imagesClient.deleteCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
deprecateAsync
public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> deprecateAsync(String project, String image, DeprecationStatus deprecationStatusResource)
Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String image = "image100313435"; DeprecationStatus deprecationStatusResource = DeprecationStatus.newBuilder().build(); Operation response = imagesClient.deprecateAsync(project, image, deprecationStatusResource).get(); }
- Parameters:
project
- Project ID for this request.image
- Image name.deprecationStatusResource
- The body resource for this request- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
deprecateAsync
@BetaApi("The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> deprecateAsync(DeprecateImageRequest request)
Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead.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 (ImagesClient imagesClient = ImagesClient.create()) { DeprecateImageRequest request = DeprecateImageRequest.newBuilder() .setDeprecationStatusResource(DeprecationStatus.newBuilder().build()) .setImage("image100313435") .setProject("project-309310695") .setRequestId("requestId693933066") .build(); Operation response = imagesClient.deprecateAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
deprecateOperationCallable
public final com.google.api.gax.rpc.OperationCallable<DeprecateImageRequest,Operation,Operation> deprecateOperationCallable()
Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead.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 (ImagesClient imagesClient = ImagesClient.create()) { DeprecateImageRequest request = DeprecateImageRequest.newBuilder() .setDeprecationStatusResource(DeprecationStatus.newBuilder().build()) .setImage("image100313435") .setProject("project-309310695") .setRequestId("requestId693933066") .build(); OperationFuture<Operation, Operation> future = imagesClient.deprecateOperationCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
deprecateCallable
public final com.google.api.gax.rpc.UnaryCallable<DeprecateImageRequest,Operation> deprecateCallable()
Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead.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 (ImagesClient imagesClient = ImagesClient.create()) { DeprecateImageRequest request = DeprecateImageRequest.newBuilder() .setDeprecationStatusResource(DeprecationStatus.newBuilder().build()) .setImage("image100313435") .setProject("project-309310695") .setRequestId("requestId693933066") .build(); ApiFuture<Operation> future = imagesClient.deprecateCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
get
public final Image get(String project, String image)
Returns the specified image.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String image = "image100313435"; Image response = imagesClient.get(project, image); }
- Parameters:
project
- Project ID for this request.image
- Name of the image resource to return.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
get
public final Image get(GetImageRequest request)
Returns the specified image.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 (ImagesClient imagesClient = ImagesClient.create()) { GetImageRequest request = GetImageRequest.newBuilder() .setImage("image100313435") .setProject("project-309310695") .build(); Image response = imagesClient.get(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getCallable
public final com.google.api.gax.rpc.UnaryCallable<GetImageRequest,Image> getCallable()
Returns the specified image.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 (ImagesClient imagesClient = ImagesClient.create()) { GetImageRequest request = GetImageRequest.newBuilder() .setImage("image100313435") .setProject("project-309310695") .build(); ApiFuture<Image> future = imagesClient.getCallable().futureCall(request); // Do something. Image response = future.get(); }
-
getFromFamily
public final Image getFromFamily(String project, String family)
Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String family = "family-1281860764"; Image response = imagesClient.getFromFamily(project, family); }
- Parameters:
project
- The image project that the image belongs to. For example, to get a CentOS image, specify centos-cloud as the image project.family
- Name of the image family to search for.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getFromFamily
public final Image getFromFamily(GetFromFamilyImageRequest request)
Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation.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 (ImagesClient imagesClient = ImagesClient.create()) { GetFromFamilyImageRequest request = GetFromFamilyImageRequest.newBuilder() .setFamily("family-1281860764") .setProject("project-309310695") .build(); Image response = imagesClient.getFromFamily(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getFromFamilyCallable
public final com.google.api.gax.rpc.UnaryCallable<GetFromFamilyImageRequest,Image> getFromFamilyCallable()
Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation.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 (ImagesClient imagesClient = ImagesClient.create()) { GetFromFamilyImageRequest request = GetFromFamilyImageRequest.newBuilder() .setFamily("family-1281860764") .setProject("project-309310695") .build(); ApiFuture<Image> future = imagesClient.getFromFamilyCallable().futureCall(request); // Do something. Image response = future.get(); }
-
getIamPolicy
public final Policy getIamPolicy(String project, String resource)
Gets the access control policy for a resource. May be empty if no such policy or resource exists.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String resource = "resource-341064690"; Policy response = imagesClient.getIamPolicy(project, resource); }
- Parameters:
project
- Project ID for this request.resource
- Name or id of the resource for this request.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIamPolicy
public final Policy getIamPolicy(GetIamPolicyImageRequest request)
Gets the access control policy for a resource. May be empty if no such policy or resource exists.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 (ImagesClient imagesClient = ImagesClient.create()) { GetIamPolicyImageRequest request = GetIamPolicyImageRequest.newBuilder() .setOptionsRequestedPolicyVersion(-574521795) .setProject("project-309310695") .setResource("resource-341064690") .build(); Policy response = imagesClient.getIamPolicy(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIamPolicyCallable
public final com.google.api.gax.rpc.UnaryCallable<GetIamPolicyImageRequest,Policy> getIamPolicyCallable()
Gets the access control policy for a resource. May be empty if no such policy or resource exists.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 (ImagesClient imagesClient = ImagesClient.create()) { GetIamPolicyImageRequest request = GetIamPolicyImageRequest.newBuilder() .setOptionsRequestedPolicyVersion(-574521795) .setProject("project-309310695") .setResource("resource-341064690") .build(); ApiFuture<Policy> future = imagesClient.getIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); }
-
insertAsync
public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> insertAsync(String project, Image imageResource)
Creates an image in the specified project using the data included in the request.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; Image imageResource = Image.newBuilder().build(); Operation response = imagesClient.insertAsync(project, imageResource).get(); }
- Parameters:
project
- Project ID for this request.imageResource
- The body resource for this request- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
insertAsync
@BetaApi("The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> insertAsync(InsertImageRequest request)
Creates an image in the specified project using the data included in the request.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 (ImagesClient imagesClient = ImagesClient.create()) { InsertImageRequest request = InsertImageRequest.newBuilder() .setForceCreate(true) .setImageResource(Image.newBuilder().build()) .setProject("project-309310695") .setRequestId("requestId693933066") .build(); Operation response = imagesClient.insertAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
insertOperationCallable
public final com.google.api.gax.rpc.OperationCallable<InsertImageRequest,Operation,Operation> insertOperationCallable()
Creates an image in the specified project using the data included in the request.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 (ImagesClient imagesClient = ImagesClient.create()) { InsertImageRequest request = InsertImageRequest.newBuilder() .setForceCreate(true) .setImageResource(Image.newBuilder().build()) .setProject("project-309310695") .setRequestId("requestId693933066") .build(); OperationFuture<Operation, Operation> future = imagesClient.insertOperationCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
insertCallable
public final com.google.api.gax.rpc.UnaryCallable<InsertImageRequest,Operation> insertCallable()
Creates an image in the specified project using the data included in the request.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 (ImagesClient imagesClient = ImagesClient.create()) { InsertImageRequest request = InsertImageRequest.newBuilder() .setForceCreate(true) .setImageResource(Image.newBuilder().build()) .setProject("project-309310695") .setRequestId("requestId693933066") .build(); ApiFuture<Operation> future = imagesClient.insertCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
list
public final ImagesClient.ListPagedResponse list(String project)
Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; for (Image element : imagesClient.list(project).iterateAll()) { // doThingsWith(element); } }
- Parameters:
project
- Project ID for this request.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
list
public final ImagesClient.ListPagedResponse list(ListImagesRequest request)
Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud.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 (ImagesClient imagesClient = ImagesClient.create()) { ListImagesRequest request = ListImagesRequest.newBuilder() .setFilter("filter-1274492040") .setMaxResults(1128457243) .setOrderBy("orderBy-1207110587") .setPageToken("pageToken873572522") .setProject("project-309310695") .setReturnPartialSuccess(true) .build(); for (Image element : imagesClient.list(request).iterateAll()) { // doThingsWith(element); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListImagesRequest,ImagesClient.ListPagedResponse> listPagedCallable()
Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud.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 (ImagesClient imagesClient = ImagesClient.create()) { ListImagesRequest request = ListImagesRequest.newBuilder() .setFilter("filter-1274492040") .setMaxResults(1128457243) .setOrderBy("orderBy-1207110587") .setPageToken("pageToken873572522") .setProject("project-309310695") .setReturnPartialSuccess(true) .build(); ApiFuture<Image> future = imagesClient.listPagedCallable().futureCall(request); // Do something. for (Image element : future.get().iterateAll()) { // doThingsWith(element); } }
-
listCallable
public final com.google.api.gax.rpc.UnaryCallable<ListImagesRequest,ImageList> listCallable()
Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud.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 (ImagesClient imagesClient = ImagesClient.create()) { ListImagesRequest request = ListImagesRequest.newBuilder() .setFilter("filter-1274492040") .setMaxResults(1128457243) .setOrderBy("orderBy-1207110587") .setPageToken("pageToken873572522") .setProject("project-309310695") .setReturnPartialSuccess(true) .build(); while (true) { ImageList response = imagesClient.listCallable().call(request); for (Image element : response.getItemsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } }
-
patchAsync
public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> patchAsync(String project, String image, Image imageResource)
Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String image = "image100313435"; Image imageResource = Image.newBuilder().build(); Operation response = imagesClient.patchAsync(project, image, imageResource).get(); }
- Parameters:
project
- Project ID for this request.image
- Name of the image resource to patch.imageResource
- The body resource for this request- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
patchAsync
@BetaApi("The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> patchAsync(PatchImageRequest request)
Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status.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 (ImagesClient imagesClient = ImagesClient.create()) { PatchImageRequest request = PatchImageRequest.newBuilder() .setImage("image100313435") .setImageResource(Image.newBuilder().build()) .setProject("project-309310695") .setRequestId("requestId693933066") .build(); Operation response = imagesClient.patchAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
patchOperationCallable
public final com.google.api.gax.rpc.OperationCallable<PatchImageRequest,Operation,Operation> patchOperationCallable()
Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status.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 (ImagesClient imagesClient = ImagesClient.create()) { PatchImageRequest request = PatchImageRequest.newBuilder() .setImage("image100313435") .setImageResource(Image.newBuilder().build()) .setProject("project-309310695") .setRequestId("requestId693933066") .build(); OperationFuture<Operation, Operation> future = imagesClient.patchOperationCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
patchCallable
public final com.google.api.gax.rpc.UnaryCallable<PatchImageRequest,Operation> patchCallable()
Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status.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 (ImagesClient imagesClient = ImagesClient.create()) { PatchImageRequest request = PatchImageRequest.newBuilder() .setImage("image100313435") .setImageResource(Image.newBuilder().build()) .setProject("project-309310695") .setRequestId("requestId693933066") .build(); ApiFuture<Operation> future = imagesClient.patchCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
setIamPolicy
public final Policy setIamPolicy(String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sets the access control policy on the specified resource. Replaces any existing policy.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String resource = "resource-341064690"; GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build(); Policy response = imagesClient.setIamPolicy(project, resource, globalSetPolicyRequestResource); }
- Parameters:
project
- Project ID for this request.resource
- Name or id of the resource for this request.globalSetPolicyRequestResource
- The body resource for this request- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setIamPolicy
public final Policy setIamPolicy(SetIamPolicyImageRequest request)
Sets the access control policy on the specified resource. Replaces any existing policy.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 (ImagesClient imagesClient = ImagesClient.create()) { SetIamPolicyImageRequest request = SetIamPolicyImageRequest.newBuilder() .setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build()) .setProject("project-309310695") .setResource("resource-341064690") .build(); Policy response = imagesClient.setIamPolicy(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setIamPolicyCallable
public final com.google.api.gax.rpc.UnaryCallable<SetIamPolicyImageRequest,Policy> setIamPolicyCallable()
Sets the access control policy on the specified resource. Replaces any existing policy.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 (ImagesClient imagesClient = ImagesClient.create()) { SetIamPolicyImageRequest request = SetIamPolicyImageRequest.newBuilder() .setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build()) .setProject("project-309310695") .setResource("resource-341064690") .build(); ApiFuture<Policy> future = imagesClient.setIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); }
-
setLabelsAsync
public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> setLabelsAsync(String project, String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)
Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String resource = "resource-341064690"; GlobalSetLabelsRequest globalSetLabelsRequestResource = GlobalSetLabelsRequest.newBuilder().build(); Operation response = imagesClient.setLabelsAsync(project, resource, globalSetLabelsRequestResource).get(); }
- Parameters:
project
- Project ID for this request.resource
- Name or id of the resource for this request.globalSetLabelsRequestResource
- The body resource for this request- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setLabelsAsync
@BetaApi("The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> setLabelsAsync(SetLabelsImageRequest request)
Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation.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 (ImagesClient imagesClient = ImagesClient.create()) { SetLabelsImageRequest request = SetLabelsImageRequest.newBuilder() .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build()) .setProject("project-309310695") .setResource("resource-341064690") .build(); Operation response = imagesClient.setLabelsAsync(request).get(); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setLabelsOperationCallable
public final com.google.api.gax.rpc.OperationCallable<SetLabelsImageRequest,Operation,Operation> setLabelsOperationCallable()
Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation.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 (ImagesClient imagesClient = ImagesClient.create()) { SetLabelsImageRequest request = SetLabelsImageRequest.newBuilder() .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build()) .setProject("project-309310695") .setResource("resource-341064690") .build(); OperationFuture<Operation, Operation> future = imagesClient.setLabelsOperationCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
setLabelsCallable
public final com.google.api.gax.rpc.UnaryCallable<SetLabelsImageRequest,Operation> setLabelsCallable()
Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation.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 (ImagesClient imagesClient = ImagesClient.create()) { SetLabelsImageRequest request = SetLabelsImageRequest.newBuilder() .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build()) .setProject("project-309310695") .setResource("resource-341064690") .build(); ApiFuture<Operation> future = imagesClient.setLabelsCallable().futureCall(request); // Do something. Operation response = future.get(); }
-
testIamPermissions
public final TestPermissionsResponse testIamPermissions(String project, String resource, TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.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 (ImagesClient imagesClient = ImagesClient.create()) { String project = "project-309310695"; String resource = "resource-341064690"; TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build(); TestPermissionsResponse response = imagesClient.testIamPermissions(project, resource, testPermissionsRequestResource); }
- Parameters:
project
- Project ID for this request.resource
- Name or id of the resource for this request.testPermissionsRequestResource
- The body resource for this request- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
testIamPermissions
public final TestPermissionsResponse testIamPermissions(TestIamPermissionsImageRequest request)
Returns permissions that a caller has on the specified resource.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 (ImagesClient imagesClient = ImagesClient.create()) { TestIamPermissionsImageRequest request = TestIamPermissionsImageRequest.newBuilder() .setProject("project-309310695") .setResource("resource-341064690") .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build()) .build(); TestPermissionsResponse response = imagesClient.testIamPermissions(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
testIamPermissionsCallable
public final com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsImageRequest,TestPermissionsResponse> testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.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 (ImagesClient imagesClient = ImagesClient.create()) { TestIamPermissionsImageRequest request = TestIamPermissionsImageRequest.newBuilder() .setProject("project-309310695") .setResource("resource-341064690") .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build()) .build(); ApiFuture<TestPermissionsResponse> future = imagesClient.testIamPermissionsCallable().futureCall(request); // Do something. TestPermissionsResponse response = future.get(); }
-
close
public final void close()
- Specified by:
close
in interfaceAutoCloseable
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfacecom.google.api.gax.core.BackgroundResource
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfacecom.google.api.gax.core.BackgroundResource
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfacecom.google.api.gax.core.BackgroundResource
-
shutdownNow
public void shutdownNow()
- Specified by:
shutdownNow
in interfacecom.google.api.gax.core.BackgroundResource
-
awaitTermination
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
- Specified by:
awaitTermination
in interfacecom.google.api.gax.core.BackgroundResource
- Throws:
InterruptedException
-
-