Class InternalPhotosLibraryClient
- java.lang.Object
-
- com.google.photos.library.v1.internal.InternalPhotosLibraryClient
-
- All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource
,java.lang.AutoCloseable
- Direct Known Subclasses:
PhotosLibraryClient
@Generated("by gapic-generator") @BetaApi public class InternalPhotosLibraryClient extends java.lang.Object implements com.google.api.gax.core.BackgroundResource
Service Description: Service which allows developers to perform the following actions on behalf of the user: - upload media items directly to their Google Photos library - create albums - add media items (including album enrichments) to albums - list and download content from their Google Photos library - filter results by media type, date range or content category - create, join, and access shared albumsThis 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 (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { Album album = Album.newBuilder().build(); Album response = internalPhotosLibraryClient.createAlbum(album); }
Note: close() needs to be called on the internalPhotosLibraryClient 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 InternalPhotosLibrarySettings to create(). For example:
To customize credentials:
InternalPhotosLibrarySettings internalPhotosLibrarySettings = InternalPhotosLibrarySettings.newBuilder() .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) .build(); InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create(internalPhotosLibrarySettings);
InternalPhotosLibrarySettings internalPhotosLibrarySettings = InternalPhotosLibrarySettings.newBuilder().setEndpoint(myEndpoint).build(); InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create(internalPhotosLibrarySettings);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InternalPhotosLibraryClient.ListAlbumsFixedSizeCollection
static class
InternalPhotosLibraryClient.ListAlbumsPage
static class
InternalPhotosLibraryClient.ListAlbumsPagedResponse
static class
InternalPhotosLibraryClient.ListMediaItemsFixedSizeCollection
static class
InternalPhotosLibraryClient.ListMediaItemsPage
static class
InternalPhotosLibraryClient.ListMediaItemsPagedResponse
static class
InternalPhotosLibraryClient.ListSharedAlbumsFixedSizeCollection
static class
InternalPhotosLibraryClient.ListSharedAlbumsPage
static class
InternalPhotosLibraryClient.ListSharedAlbumsPagedResponse
static class
InternalPhotosLibraryClient.SearchMediaItemsFixedSizeCollection
static class
InternalPhotosLibraryClient.SearchMediaItemsPage
static class
InternalPhotosLibraryClient.SearchMediaItemsPagedResponse
-
Constructor Summary
Constructors Modifier Constructor Description protected
InternalPhotosLibraryClient(InternalPhotosLibrarySettings settings)
Constructs an instance of InternalPhotosLibraryClient, using the given settings.protected
InternalPhotosLibraryClient(PhotosLibraryStub stub)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AddEnrichmentToAlbumResponse
addEnrichmentToAlbum(AddEnrichmentToAlbumRequest request)
Adds an enrichment at a specified position in a defined album.AddEnrichmentToAlbumResponse
addEnrichmentToAlbum(java.lang.String albumId, NewEnrichmentItem newEnrichmentItem, AlbumPosition albumPosition)
Adds an enrichment at a specified position in a defined album.com.google.api.gax.rpc.UnaryCallable<AddEnrichmentToAlbumRequest,AddEnrichmentToAlbumResponse>
addEnrichmentToAlbumCallable()
Adds an enrichment at a specified position in a defined album.boolean
awaitTermination(long duration, java.util.concurrent.TimeUnit unit)
BatchAddMediaItemsToAlbumResponse
batchAddMediaItemsToAlbum(BatchAddMediaItemsToAlbumRequest request)
Adds one or more media items in a user's Google Photos library to an album.BatchAddMediaItemsToAlbumResponse
batchAddMediaItemsToAlbum(java.lang.String albumId, java.util.List<java.lang.String> mediaItemIds)
Adds one or more media items in a user's Google Photos library to an album.com.google.api.gax.rpc.UnaryCallable<BatchAddMediaItemsToAlbumRequest,BatchAddMediaItemsToAlbumResponse>
batchAddMediaItemsToAlbumCallable()
Adds one or more media items in a user's Google Photos library to an album.BatchCreateMediaItemsResponse
batchCreateMediaItems(BatchCreateMediaItemsRequest request)
Creates one or more media items in a user's Google Photos library.BatchCreateMediaItemsResponse
batchCreateMediaItems(java.lang.String albumId, java.util.List<NewMediaItem> newMediaItems, AlbumPosition albumPosition)
Creates one or more media items in a user's Google Photos library.com.google.api.gax.rpc.UnaryCallable<BatchCreateMediaItemsRequest,BatchCreateMediaItemsResponse>
batchCreateMediaItemsCallable()
Creates one or more media items in a user's Google Photos library.BatchGetMediaItemsResponse
batchGetMediaItems(BatchGetMediaItemsRequest request)
Returns the list of media items for the specified media item identifiers.BatchGetMediaItemsResponse
batchGetMediaItems(java.util.List<java.lang.String> mediaItemIds)
Returns the list of media items for the specified media item identifiers.com.google.api.gax.rpc.UnaryCallable<BatchGetMediaItemsRequest,BatchGetMediaItemsResponse>
batchGetMediaItemsCallable()
Returns the list of media items for the specified media item identifiers.BatchRemoveMediaItemsFromAlbumResponse
batchRemoveMediaItemsFromAlbum(BatchRemoveMediaItemsFromAlbumRequest request)
Removes one or more media items from a specified album.BatchRemoveMediaItemsFromAlbumResponse
batchRemoveMediaItemsFromAlbum(java.lang.String albumId, java.util.List<java.lang.String> mediaItemIds)
Removes one or more media items from a specified album.com.google.api.gax.rpc.UnaryCallable<BatchRemoveMediaItemsFromAlbumRequest,BatchRemoveMediaItemsFromAlbumResponse>
batchRemoveMediaItemsFromAlbumCallable()
Removes one or more media items from a specified album.void
close()
static InternalPhotosLibraryClient
create()
Constructs an instance of InternalPhotosLibraryClient with default settings.static InternalPhotosLibraryClient
create(InternalPhotosLibrarySettings settings)
Constructs an instance of InternalPhotosLibraryClient, using the given settings.static InternalPhotosLibraryClient
create(PhotosLibraryStub stub)
Constructs an instance of InternalPhotosLibraryClient, using the given stub for making calls.Album
createAlbum(CreateAlbumRequest request)
Creates an album in a user's Google Photos library.Album
createAlbum(Album album)
Creates an album in a user's Google Photos library.com.google.api.gax.rpc.UnaryCallable<CreateAlbumRequest,Album>
createAlbumCallable()
Creates an album in a user's Google Photos library.Album
getAlbum(GetAlbumRequest request)
Returns the album based on the specified `albumId`.Album
getAlbum(java.lang.String albumId)
Returns the album based on the specified `albumId`.com.google.api.gax.rpc.UnaryCallable<GetAlbumRequest,Album>
getAlbumCallable()
Returns the album based on the specified `albumId`.MediaItem
getMediaItem(GetMediaItemRequest request)
Returns the media item for the specified media item identifier.MediaItem
getMediaItem(java.lang.String mediaItemId)
Returns the media item for the specified media item identifier.com.google.api.gax.rpc.UnaryCallable<GetMediaItemRequest,MediaItem>
getMediaItemCallable()
Returns the media item for the specified media item identifier.InternalPhotosLibrarySettings
getSettings()
Album
getSharedAlbum(GetSharedAlbumRequest request)
Returns the album based on the specified `shareToken`.Album
getSharedAlbum(java.lang.String shareToken)
Returns the album based on the specified `shareToken`.com.google.api.gax.rpc.UnaryCallable<GetSharedAlbumRequest,Album>
getSharedAlbumCallable()
Returns the album based on the specified `shareToken`.PhotosLibraryStub
getStub()
boolean
isShutdown()
boolean
isTerminated()
JoinSharedAlbumResponse
joinSharedAlbum(JoinSharedAlbumRequest request)
Joins a shared album on behalf of the Google Photos user.JoinSharedAlbumResponse
joinSharedAlbum(java.lang.String shareToken)
Joins a shared album on behalf of the Google Photos user.com.google.api.gax.rpc.UnaryCallable<JoinSharedAlbumRequest,JoinSharedAlbumResponse>
joinSharedAlbumCallable()
Joins a shared album on behalf of the Google Photos user.LeaveSharedAlbumResponse
leaveSharedAlbum(LeaveSharedAlbumRequest request)
Leaves a previously-joined shared album on behalf of the Google Photos user.LeaveSharedAlbumResponse
leaveSharedAlbum(java.lang.String shareToken)
Leaves a previously-joined shared album on behalf of the Google Photos user.com.google.api.gax.rpc.UnaryCallable<LeaveSharedAlbumRequest,LeaveSharedAlbumResponse>
leaveSharedAlbumCallable()
Leaves a previously-joined shared album on behalf of the Google Photos user.InternalPhotosLibraryClient.ListAlbumsPagedResponse
listAlbums(boolean excludeNonAppCreatedData)
Lists all albums shown to a user in the Albums tab of the Google Photos app.InternalPhotosLibraryClient.ListAlbumsPagedResponse
listAlbums(ListAlbumsRequest request)
Lists all albums shown to a user in the Albums tab of the Google Photos app.com.google.api.gax.rpc.UnaryCallable<ListAlbumsRequest,ListAlbumsResponse>
listAlbumsCallable()
Lists all albums shown to a user in the Albums tab of the Google Photos app.com.google.api.gax.rpc.UnaryCallable<ListAlbumsRequest,InternalPhotosLibraryClient.ListAlbumsPagedResponse>
listAlbumsPagedCallable()
Lists all albums shown to a user in the Albums tab of the Google Photos app.InternalPhotosLibraryClient.ListMediaItemsPagedResponse
listMediaItems(ListMediaItemsRequest request)
List all media items from a user's Google Photos library.com.google.api.gax.rpc.UnaryCallable<ListMediaItemsRequest,ListMediaItemsResponse>
listMediaItemsCallable()
List all media items from a user's Google Photos library.com.google.api.gax.rpc.UnaryCallable<ListMediaItemsRequest,InternalPhotosLibraryClient.ListMediaItemsPagedResponse>
listMediaItemsPagedCallable()
List all media items from a user's Google Photos library.InternalPhotosLibraryClient.ListSharedAlbumsPagedResponse
listSharedAlbums(boolean excludeNonAppCreatedData)
Lists all shared albums available in the Sharing tab of the user's Google Photos app.InternalPhotosLibraryClient.ListSharedAlbumsPagedResponse
listSharedAlbums(ListSharedAlbumsRequest request)
Lists all shared albums available in the Sharing tab of the user's Google Photos app.com.google.api.gax.rpc.UnaryCallable<ListSharedAlbumsRequest,ListSharedAlbumsResponse>
listSharedAlbumsCallable()
Lists all shared albums available in the Sharing tab of the user's Google Photos app.com.google.api.gax.rpc.UnaryCallable<ListSharedAlbumsRequest,InternalPhotosLibraryClient.ListSharedAlbumsPagedResponse>
listSharedAlbumsPagedCallable()
Lists all shared albums available in the Sharing tab of the user's Google Photos app.InternalPhotosLibraryClient.SearchMediaItemsPagedResponse
searchMediaItems(Filters filters)
Searches for media items in a user's Google Photos library.InternalPhotosLibraryClient.SearchMediaItemsPagedResponse
searchMediaItems(SearchMediaItemsRequest request)
Searches for media items in a user's Google Photos library.InternalPhotosLibraryClient.SearchMediaItemsPagedResponse
searchMediaItems(java.lang.String albumId)
Searches for media items in a user's Google Photos library.com.google.api.gax.rpc.UnaryCallable<SearchMediaItemsRequest,SearchMediaItemsResponse>
searchMediaItemsCallable()
Searches for media items in a user's Google Photos library.com.google.api.gax.rpc.UnaryCallable<SearchMediaItemsRequest,InternalPhotosLibraryClient.SearchMediaItemsPagedResponse>
searchMediaItemsPagedCallable()
Searches for media items in a user's Google Photos library.ShareAlbumResponse
shareAlbum(ShareAlbumRequest request)
Marks an album as shared and accessible to other users.ShareAlbumResponse
shareAlbum(java.lang.String albumId, SharedAlbumOptions sharedAlbumOptions)
Marks an album as shared and accessible to other users.com.google.api.gax.rpc.UnaryCallable<ShareAlbumRequest,ShareAlbumResponse>
shareAlbumCallable()
Marks an album as shared and accessible to other users.void
shutdown()
void
shutdownNow()
UnshareAlbumResponse
unshareAlbum(UnshareAlbumRequest request)
Marks a previously shared album as private.UnshareAlbumResponse
unshareAlbum(java.lang.String albumId)
Marks a previously shared album as private.com.google.api.gax.rpc.UnaryCallable<UnshareAlbumRequest,UnshareAlbumResponse>
unshareAlbumCallable()
Marks a previously shared album as private.
-
-
-
Constructor Detail
-
InternalPhotosLibraryClient
protected InternalPhotosLibraryClient(InternalPhotosLibrarySettings settings) throws java.io.IOException
Constructs an instance of InternalPhotosLibraryClient, 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:
java.io.IOException
-
InternalPhotosLibraryClient
@BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected InternalPhotosLibraryClient(PhotosLibraryStub stub)
-
-
Method Detail
-
create
public static final InternalPhotosLibraryClient create() throws java.io.IOException
Constructs an instance of InternalPhotosLibraryClient with default settings.- Throws:
java.io.IOException
-
create
public static final InternalPhotosLibraryClient create(InternalPhotosLibrarySettings settings) throws java.io.IOException
Constructs an instance of InternalPhotosLibraryClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
java.io.IOException
-
create
@BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final InternalPhotosLibraryClient create(PhotosLibraryStub stub)
Constructs an instance of InternalPhotosLibraryClient, using the given stub for making calls. This is for advanced usage - prefer to use InternalPhotosLibrarySettings}.
-
getSettings
public final InternalPhotosLibrarySettings getSettings()
-
getStub
@BetaApi("A restructuring of stub classes is planned, so this may break in the future") public PhotosLibraryStub getStub()
-
createAlbum
public final Album createAlbum(Album album)
Creates an album in a user's Google Photos library.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { Album album = Album.newBuilder().build(); Album response = internalPhotosLibraryClient.createAlbum(album); }
- Parameters:
album
- The album to be created.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createAlbum
public final Album createAlbum(CreateAlbumRequest request)
Creates an album in a user's Google Photos library.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { Album album = Album.newBuilder().build(); CreateAlbumRequest request = CreateAlbumRequest.newBuilder() .setAlbum(album) .build(); Album response = internalPhotosLibraryClient.createAlbum(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
-
createAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<CreateAlbumRequest,Album> createAlbumCallable()
Creates an album in a user's Google Photos library.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { Album album = Album.newBuilder().build(); CreateAlbumRequest request = CreateAlbumRequest.newBuilder() .setAlbum(album) .build(); ApiFuture<Album> future = internalPhotosLibraryClient.createAlbumCallable().futureCall(request); // Do something Album response = future.get(); }
-
batchCreateMediaItems
public final BatchCreateMediaItemsResponse batchCreateMediaItems(java.lang.String albumId, java.util.List<NewMediaItem> newMediaItems, AlbumPosition albumPosition)
Creates one or more media items in a user's Google Photos library.This is the second step for creating a media item. For details regarding Step 1, uploading the raw bytes to a Google Server, see <a href="/photos/library/guides/upload-media">Uploading media</a>.
This call adds the media item to the library. If an album `id` is specified, the call adds the media item to the album too. Each album can contain up to 20,000 media items. By default, the media item will be added to the end of the library or album.
If an album `id` and position are both defined, the media item is added to the album at the specified position.
If the call contains multiple media items, they're added at the specified position. If you are creating a media item in a shared album where you are not the owner, you are not allowed to position the media item. Doing so will result in a `BAD REQUEST` error.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; List<NewMediaItem> newMediaItems = new ArrayList<>(); AlbumPosition albumPosition = AlbumPosition.newBuilder().build(); BatchCreateMediaItemsResponse response = internalPhotosLibraryClient.batchCreateMediaItems(albumId, newMediaItems, albumPosition); }
- Parameters:
albumId
- Identifier of the album where the media items are added. The media items are also added to the user's library. This is an optional field.newMediaItems
- List of media items to be created.albumPosition
- Position in the album where the media items are added. If not specified, the media items are added to the end of the album (as per the default value, that is, `LAST_IN_ALBUM`). The request fails if this field is set and the `albumId` is not specified. The request will also fail if you set the field and are not the owner of the shared album.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
batchCreateMediaItems
public final BatchCreateMediaItemsResponse batchCreateMediaItems(BatchCreateMediaItemsRequest request)
Creates one or more media items in a user's Google Photos library.This is the second step for creating a media item. For details regarding Step 1, uploading the raw bytes to a Google Server, see <a href="/photos/library/guides/upload-media">Uploading media</a>.
This call adds the media item to the library. If an album `id` is specified, the call adds the media item to the album too. Each album can contain up to 20,000 media items. By default, the media item will be added to the end of the library or album.
If an album `id` and position are both defined, the media item is added to the album at the specified position.
If the call contains multiple media items, they're added at the specified position. If you are creating a media item in a shared album where you are not the owner, you are not allowed to position the media item. Doing so will result in a `BAD REQUEST` error.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { List<NewMediaItem> newMediaItems = new ArrayList<>(); BatchCreateMediaItemsRequest request = BatchCreateMediaItemsRequest.newBuilder() .addAllNewMediaItems(newMediaItems) .build(); BatchCreateMediaItemsResponse response = internalPhotosLibraryClient.batchCreateMediaItems(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
-
batchCreateMediaItemsCallable
public final com.google.api.gax.rpc.UnaryCallable<BatchCreateMediaItemsRequest,BatchCreateMediaItemsResponse> batchCreateMediaItemsCallable()
Creates one or more media items in a user's Google Photos library.This is the second step for creating a media item. For details regarding Step 1, uploading the raw bytes to a Google Server, see <a href="/photos/library/guides/upload-media">Uploading media</a>.
This call adds the media item to the library. If an album `id` is specified, the call adds the media item to the album too. Each album can contain up to 20,000 media items. By default, the media item will be added to the end of the library or album.
If an album `id` and position are both defined, the media item is added to the album at the specified position.
If the call contains multiple media items, they're added at the specified position. If you are creating a media item in a shared album where you are not the owner, you are not allowed to position the media item. Doing so will result in a `BAD REQUEST` error.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { List<NewMediaItem> newMediaItems = new ArrayList<>(); BatchCreateMediaItemsRequest request = BatchCreateMediaItemsRequest.newBuilder() .addAllNewMediaItems(newMediaItems) .build(); ApiFuture<BatchCreateMediaItemsResponse> future = internalPhotosLibraryClient.batchCreateMediaItemsCallable().futureCall(request); // Do something BatchCreateMediaItemsResponse response = future.get(); }
-
batchAddMediaItemsToAlbum
public final BatchAddMediaItemsToAlbumResponse batchAddMediaItemsToAlbum(java.lang.String albumId, java.util.List<java.lang.String> mediaItemIds)
Adds one or more media items in a user's Google Photos library to an album. The media items and albums must have been created by the developer via the API.Media items are added to the end of the album. If multiple media items are given, they are added in the order specified in this call.
Each album can contain up to 20,000 media items.
Only media items that are in the user's library can be added to an album. For albums that are shared, the album must either be owned by the user or the user must have joined the album as a collaborator.
Partial success is not supported. The entire request will fail if an invalid media item or album is specified.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; List<String> mediaItemIds = new ArrayList<>(); BatchAddMediaItemsToAlbumResponse response = internalPhotosLibraryClient.batchAddMediaItemsToAlbum(albumId, mediaItemIds); }
- Parameters:
albumId
- Identifier of the [Album][google.photos.types.Album] that the media items are added to.mediaItemIds
- Identifiers of the [MediaItem][google.photos.types.MediaItem]s to be added. The maximum number of media items that can be added in one call is 50.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
batchAddMediaItemsToAlbum
public final BatchAddMediaItemsToAlbumResponse batchAddMediaItemsToAlbum(BatchAddMediaItemsToAlbumRequest request)
Adds one or more media items in a user's Google Photos library to an album. The media items and albums must have been created by the developer via the API.Media items are added to the end of the album. If multiple media items are given, they are added in the order specified in this call.
Each album can contain up to 20,000 media items.
Only media items that are in the user's library can be added to an album. For albums that are shared, the album must either be owned by the user or the user must have joined the album as a collaborator.
Partial success is not supported. The entire request will fail if an invalid media item or album is specified.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; List<String> mediaItemIds = new ArrayList<>(); BatchAddMediaItemsToAlbumRequest request = BatchAddMediaItemsToAlbumRequest.newBuilder() .setAlbumId(albumId) .addAllMediaItemIds(mediaItemIds) .build(); BatchAddMediaItemsToAlbumResponse response = internalPhotosLibraryClient.batchAddMediaItemsToAlbum(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
-
batchAddMediaItemsToAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<BatchAddMediaItemsToAlbumRequest,BatchAddMediaItemsToAlbumResponse> batchAddMediaItemsToAlbumCallable()
Adds one or more media items in a user's Google Photos library to an album. The media items and albums must have been created by the developer via the API.Media items are added to the end of the album. If multiple media items are given, they are added in the order specified in this call.
Each album can contain up to 20,000 media items.
Only media items that are in the user's library can be added to an album. For albums that are shared, the album must either be owned by the user or the user must have joined the album as a collaborator.
Partial success is not supported. The entire request will fail if an invalid media item or album is specified.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; List<String> mediaItemIds = new ArrayList<>(); BatchAddMediaItemsToAlbumRequest request = BatchAddMediaItemsToAlbumRequest.newBuilder() .setAlbumId(albumId) .addAllMediaItemIds(mediaItemIds) .build(); ApiFuture<BatchAddMediaItemsToAlbumResponse> future = internalPhotosLibraryClient.batchAddMediaItemsToAlbumCallable().futureCall(request); // Do something BatchAddMediaItemsToAlbumResponse response = future.get(); }
-
searchMediaItems
public final InternalPhotosLibraryClient.SearchMediaItemsPagedResponse searchMediaItems(java.lang.String albumId)
Searches for media items in a user's Google Photos library. If no filters are set, then all media items in the user's library are returned. If an album is set, all media items in the specified album are returned. If filters are specified, media items that match the filters from the user's library are listed. If you set both the album and the filters, the request results in an error.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; for (MediaItem element : internalPhotosLibraryClient.searchMediaItems(albumId).iterateAll()) { // doThingsWith(element); } }
- Parameters:
albumId
- Identifier of an album. If populated, lists all media items in specified album. Can't set in conjunction with any filters.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
searchMediaItems
public final InternalPhotosLibraryClient.SearchMediaItemsPagedResponse searchMediaItems(Filters filters)
Searches for media items in a user's Google Photos library. If no filters are set, then all media items in the user's library are returned. If an album is set, all media items in the specified album are returned. If filters are specified, media items that match the filters from the user's library are listed. If you set both the album and the filters, the request results in an error.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { Filters filters = Filters.newBuilder().build(); for (MediaItem element : internalPhotosLibraryClient.searchMediaItems(filters).iterateAll()) { // doThingsWith(element); } }
- Parameters:
filters
- Filters to apply to the request. Can't be set in conjunction with an `albumId`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
searchMediaItems
public final InternalPhotosLibraryClient.SearchMediaItemsPagedResponse searchMediaItems(SearchMediaItemsRequest request)
Searches for media items in a user's Google Photos library. If no filters are set, then all media items in the user's library are returned. If an album is set, all media items in the specified album are returned. If filters are specified, media items that match the filters from the user's library are listed. If you set both the album and the filters, the request results in an error.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { SearchMediaItemsRequest request = SearchMediaItemsRequest.newBuilder().build(); for (MediaItem element : internalPhotosLibraryClient.searchMediaItems(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
-
searchMediaItemsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<SearchMediaItemsRequest,InternalPhotosLibraryClient.SearchMediaItemsPagedResponse> searchMediaItemsPagedCallable()
Searches for media items in a user's Google Photos library. If no filters are set, then all media items in the user's library are returned. If an album is set, all media items in the specified album are returned. If filters are specified, media items that match the filters from the user's library are listed. If you set both the album and the filters, the request results in an error.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { SearchMediaItemsRequest request = SearchMediaItemsRequest.newBuilder().build(); ApiFuture<SearchMediaItemsPagedResponse> future = internalPhotosLibraryClient.searchMediaItemsPagedCallable().futureCall(request); // Do something for (MediaItem element : future.get().iterateAll()) { // doThingsWith(element); } }
-
searchMediaItemsCallable
public final com.google.api.gax.rpc.UnaryCallable<SearchMediaItemsRequest,SearchMediaItemsResponse> searchMediaItemsCallable()
Searches for media items in a user's Google Photos library. If no filters are set, then all media items in the user's library are returned. If an album is set, all media items in the specified album are returned. If filters are specified, media items that match the filters from the user's library are listed. If you set both the album and the filters, the request results in an error.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { SearchMediaItemsRequest request = SearchMediaItemsRequest.newBuilder().build(); while (true) { SearchMediaItemsResponse response = internalPhotosLibraryClient.searchMediaItemsCallable().call(request); for (MediaItem element : response.getMediaItemsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } }
-
listMediaItems
public final InternalPhotosLibraryClient.ListMediaItemsPagedResponse listMediaItems(ListMediaItemsRequest request)
List all media items from a user's Google Photos library.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListMediaItemsRequest request = ListMediaItemsRequest.newBuilder().build(); for (MediaItem element : internalPhotosLibraryClient.listMediaItems(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
-
listMediaItemsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListMediaItemsRequest,InternalPhotosLibraryClient.ListMediaItemsPagedResponse> listMediaItemsPagedCallable()
List all media items from a user's Google Photos library.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListMediaItemsRequest request = ListMediaItemsRequest.newBuilder().build(); ApiFuture<ListMediaItemsPagedResponse> future = internalPhotosLibraryClient.listMediaItemsPagedCallable().futureCall(request); // Do something for (MediaItem element : future.get().iterateAll()) { // doThingsWith(element); } }
-
listMediaItemsCallable
public final com.google.api.gax.rpc.UnaryCallable<ListMediaItemsRequest,ListMediaItemsResponse> listMediaItemsCallable()
List all media items from a user's Google Photos library.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListMediaItemsRequest request = ListMediaItemsRequest.newBuilder().build(); while (true) { ListMediaItemsResponse response = internalPhotosLibraryClient.listMediaItemsCallable().call(request); for (MediaItem element : response.getMediaItemsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } }
-
getMediaItem
public final MediaItem getMediaItem(java.lang.String mediaItemId)
Returns the media item for the specified media item identifier.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String mediaItemId = ""; MediaItem response = internalPhotosLibraryClient.getMediaItem(mediaItemId); }
- Parameters:
mediaItemId
- Identifier of the media item to be requested.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getMediaItem
public final MediaItem getMediaItem(GetMediaItemRequest request)
Returns the media item for the specified media item identifier.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String mediaItemId = ""; GetMediaItemRequest request = GetMediaItemRequest.newBuilder() .setMediaItemId(mediaItemId) .build(); MediaItem response = internalPhotosLibraryClient.getMediaItem(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
-
getMediaItemCallable
public final com.google.api.gax.rpc.UnaryCallable<GetMediaItemRequest,MediaItem> getMediaItemCallable()
Returns the media item for the specified media item identifier.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String mediaItemId = ""; GetMediaItemRequest request = GetMediaItemRequest.newBuilder() .setMediaItemId(mediaItemId) .build(); ApiFuture<MediaItem> future = internalPhotosLibraryClient.getMediaItemCallable().futureCall(request); // Do something MediaItem response = future.get(); }
-
batchGetMediaItems
public final BatchGetMediaItemsResponse batchGetMediaItems(java.util.List<java.lang.String> mediaItemIds)
Returns the list of media items for the specified media item identifiers. Items are returned in the same order as the supplied identifiers.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { List<String> mediaItemIds = new ArrayList<>(); BatchGetMediaItemsResponse response = internalPhotosLibraryClient.batchGetMediaItems(mediaItemIds); }
- Parameters:
mediaItemIds
- Identifiers of the media items to be requested. Must not contain repeated identifiers and cannot be empty. The maximum number of media items that can be retrieved in one call is 50.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
batchGetMediaItems
public final BatchGetMediaItemsResponse batchGetMediaItems(BatchGetMediaItemsRequest request)
Returns the list of media items for the specified media item identifiers. Items are returned in the same order as the supplied identifiers.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { List<String> mediaItemIds = new ArrayList<>(); BatchGetMediaItemsRequest request = BatchGetMediaItemsRequest.newBuilder() .addAllMediaItemIds(mediaItemIds) .build(); BatchGetMediaItemsResponse response = internalPhotosLibraryClient.batchGetMediaItems(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
-
batchGetMediaItemsCallable
public final com.google.api.gax.rpc.UnaryCallable<BatchGetMediaItemsRequest,BatchGetMediaItemsResponse> batchGetMediaItemsCallable()
Returns the list of media items for the specified media item identifiers. Items are returned in the same order as the supplied identifiers.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { List<String> mediaItemIds = new ArrayList<>(); BatchGetMediaItemsRequest request = BatchGetMediaItemsRequest.newBuilder() .addAllMediaItemIds(mediaItemIds) .build(); ApiFuture<BatchGetMediaItemsResponse> future = internalPhotosLibraryClient.batchGetMediaItemsCallable().futureCall(request); // Do something BatchGetMediaItemsResponse response = future.get(); }
-
listAlbums
public final InternalPhotosLibraryClient.ListAlbumsPagedResponse listAlbums(boolean excludeNonAppCreatedData)
Lists all albums shown to a user in the Albums tab of the Google Photos app.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { boolean excludeNonAppCreatedData = false; for (Album element : internalPhotosLibraryClient.listAlbums(excludeNonAppCreatedData).iterateAll()) { // doThingsWith(element); } }
- Parameters:
excludeNonAppCreatedData
- If set, the results exclude media items that were not created by this app. Defaults to false (all albums are returned). This field is ignored if the photoslibrary.readonly.appcreateddata scope is used.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listAlbums
public final InternalPhotosLibraryClient.ListAlbumsPagedResponse listAlbums(ListAlbumsRequest request)
Lists all albums shown to a user in the Albums tab of the Google Photos app.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListAlbumsRequest request = ListAlbumsRequest.newBuilder().build(); for (Album element : internalPhotosLibraryClient.listAlbums(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
-
listAlbumsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListAlbumsRequest,InternalPhotosLibraryClient.ListAlbumsPagedResponse> listAlbumsPagedCallable()
Lists all albums shown to a user in the Albums tab of the Google Photos app.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListAlbumsRequest request = ListAlbumsRequest.newBuilder().build(); ApiFuture<ListAlbumsPagedResponse> future = internalPhotosLibraryClient.listAlbumsPagedCallable().futureCall(request); // Do something for (Album element : future.get().iterateAll()) { // doThingsWith(element); } }
-
listAlbumsCallable
public final com.google.api.gax.rpc.UnaryCallable<ListAlbumsRequest,ListAlbumsResponse> listAlbumsCallable()
Lists all albums shown to a user in the Albums tab of the Google Photos app.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListAlbumsRequest request = ListAlbumsRequest.newBuilder().build(); while (true) { ListAlbumsResponse response = internalPhotosLibraryClient.listAlbumsCallable().call(request); for (Album element : response.getAlbumsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } }
-
getAlbum
public final Album getAlbum(java.lang.String albumId)
Returns the album based on the specified `albumId`. The `albumId` must be the ID of an album owned by the user or a shared album that the user has joined.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; Album response = internalPhotosLibraryClient.getAlbum(albumId); }
- Parameters:
albumId
- Identifier of the album to be requested.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getAlbum
public final Album getAlbum(GetAlbumRequest request)
Returns the album based on the specified `albumId`. The `albumId` must be the ID of an album owned by the user or a shared album that the user has joined.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; GetAlbumRequest request = GetAlbumRequest.newBuilder() .setAlbumId(albumId) .build(); Album response = internalPhotosLibraryClient.getAlbum(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
-
getAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<GetAlbumRequest,Album> getAlbumCallable()
Returns the album based on the specified `albumId`. The `albumId` must be the ID of an album owned by the user or a shared album that the user has joined.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; GetAlbumRequest request = GetAlbumRequest.newBuilder() .setAlbumId(albumId) .build(); ApiFuture<Album> future = internalPhotosLibraryClient.getAlbumCallable().futureCall(request); // Do something Album response = future.get(); }
-
getSharedAlbum
public final Album getSharedAlbum(java.lang.String shareToken)
Returns the album based on the specified `shareToken`.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; Album response = internalPhotosLibraryClient.getSharedAlbum(shareToken); }
- Parameters:
shareToken
- Share token of the album to be requested.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getSharedAlbum
public final Album getSharedAlbum(GetSharedAlbumRequest request)
Returns the album based on the specified `shareToken`.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; GetSharedAlbumRequest request = GetSharedAlbumRequest.newBuilder() .setShareToken(shareToken) .build(); Album response = internalPhotosLibraryClient.getSharedAlbum(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
-
getSharedAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<GetSharedAlbumRequest,Album> getSharedAlbumCallable()
Returns the album based on the specified `shareToken`.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; GetSharedAlbumRequest request = GetSharedAlbumRequest.newBuilder() .setShareToken(shareToken) .build(); ApiFuture<Album> future = internalPhotosLibraryClient.getSharedAlbumCallable().futureCall(request); // Do something Album response = future.get(); }
-
addEnrichmentToAlbum
public final AddEnrichmentToAlbumResponse addEnrichmentToAlbum(java.lang.String albumId, NewEnrichmentItem newEnrichmentItem, AlbumPosition albumPosition)
Adds an enrichment at a specified position in a defined album.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; NewEnrichmentItem newEnrichmentItem = NewEnrichmentItem.newBuilder().build(); AlbumPosition albumPosition = AlbumPosition.newBuilder().build(); AddEnrichmentToAlbumResponse response = internalPhotosLibraryClient.addEnrichmentToAlbum(albumId, newEnrichmentItem, albumPosition); }
- Parameters:
albumId
- Identifier of the album where the enrichment is to be added.newEnrichmentItem
- The enrichment to be added.albumPosition
- The position in the album where the enrichment is to be inserted.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
addEnrichmentToAlbum
public final AddEnrichmentToAlbumResponse addEnrichmentToAlbum(AddEnrichmentToAlbumRequest request)
Adds an enrichment at a specified position in a defined album.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; NewEnrichmentItem newEnrichmentItem = NewEnrichmentItem.newBuilder().build(); AlbumPosition albumPosition = AlbumPosition.newBuilder().build(); AddEnrichmentToAlbumRequest request = AddEnrichmentToAlbumRequest.newBuilder() .setAlbumId(albumId) .setNewEnrichmentItem(newEnrichmentItem) .setAlbumPosition(albumPosition) .build(); AddEnrichmentToAlbumResponse response = internalPhotosLibraryClient.addEnrichmentToAlbum(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
-
addEnrichmentToAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<AddEnrichmentToAlbumRequest,AddEnrichmentToAlbumResponse> addEnrichmentToAlbumCallable()
Adds an enrichment at a specified position in a defined album.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; NewEnrichmentItem newEnrichmentItem = NewEnrichmentItem.newBuilder().build(); AlbumPosition albumPosition = AlbumPosition.newBuilder().build(); AddEnrichmentToAlbumRequest request = AddEnrichmentToAlbumRequest.newBuilder() .setAlbumId(albumId) .setNewEnrichmentItem(newEnrichmentItem) .setAlbumPosition(albumPosition) .build(); ApiFuture<AddEnrichmentToAlbumResponse> future = internalPhotosLibraryClient.addEnrichmentToAlbumCallable().futureCall(request); // Do something AddEnrichmentToAlbumResponse response = future.get(); }
-
joinSharedAlbum
public final JoinSharedAlbumResponse joinSharedAlbum(java.lang.String shareToken)
Joins a shared album on behalf of the Google Photos user.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; JoinSharedAlbumResponse response = internalPhotosLibraryClient.joinSharedAlbum(shareToken); }
- Parameters:
shareToken
- Token to join the shared album on behalf of the user.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
joinSharedAlbum
public final JoinSharedAlbumResponse joinSharedAlbum(JoinSharedAlbumRequest request)
Joins a shared album on behalf of the Google Photos user.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; JoinSharedAlbumRequest request = JoinSharedAlbumRequest.newBuilder() .setShareToken(shareToken) .build(); JoinSharedAlbumResponse response = internalPhotosLibraryClient.joinSharedAlbum(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
-
joinSharedAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<JoinSharedAlbumRequest,JoinSharedAlbumResponse> joinSharedAlbumCallable()
Joins a shared album on behalf of the Google Photos user.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; JoinSharedAlbumRequest request = JoinSharedAlbumRequest.newBuilder() .setShareToken(shareToken) .build(); ApiFuture<JoinSharedAlbumResponse> future = internalPhotosLibraryClient.joinSharedAlbumCallable().futureCall(request); // Do something JoinSharedAlbumResponse response = future.get(); }
-
leaveSharedAlbum
public final LeaveSharedAlbumResponse leaveSharedAlbum(java.lang.String shareToken)
Leaves a previously-joined shared album on behalf of the Google Photos user. The user must not own this album.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; LeaveSharedAlbumResponse response = internalPhotosLibraryClient.leaveSharedAlbum(shareToken); }
- Parameters:
shareToken
- Token to leave the shared album on behalf of the user.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
leaveSharedAlbum
public final LeaveSharedAlbumResponse leaveSharedAlbum(LeaveSharedAlbumRequest request)
Leaves a previously-joined shared album on behalf of the Google Photos user. The user must not own this album.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; LeaveSharedAlbumRequest request = LeaveSharedAlbumRequest.newBuilder() .setShareToken(shareToken) .build(); LeaveSharedAlbumResponse response = internalPhotosLibraryClient.leaveSharedAlbum(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
-
leaveSharedAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<LeaveSharedAlbumRequest,LeaveSharedAlbumResponse> leaveSharedAlbumCallable()
Leaves a previously-joined shared album on behalf of the Google Photos user. The user must not own this album.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String shareToken = ""; LeaveSharedAlbumRequest request = LeaveSharedAlbumRequest.newBuilder() .setShareToken(shareToken) .build(); ApiFuture<LeaveSharedAlbumResponse> future = internalPhotosLibraryClient.leaveSharedAlbumCallable().futureCall(request); // Do something LeaveSharedAlbumResponse response = future.get(); }
-
shareAlbum
public final ShareAlbumResponse shareAlbum(java.lang.String albumId, SharedAlbumOptions sharedAlbumOptions)
Marks an album as shared and accessible to other users. This action can only be performed on albums which were created by the developer via the API.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; SharedAlbumOptions sharedAlbumOptions = SharedAlbumOptions.newBuilder().build(); ShareAlbumResponse response = internalPhotosLibraryClient.shareAlbum(albumId, sharedAlbumOptions); }
- Parameters:
albumId
- Identifier of the album to be shared. This `albumId` must belong to an album created by the developer.sharedAlbumOptions
- Options to be set when converting the album to a shared album.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
shareAlbum
public final ShareAlbumResponse shareAlbum(ShareAlbumRequest request)
Marks an album as shared and accessible to other users. This action can only be performed on albums which were created by the developer via the API.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; ShareAlbumRequest request = ShareAlbumRequest.newBuilder() .setAlbumId(albumId) .build(); ShareAlbumResponse response = internalPhotosLibraryClient.shareAlbum(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
-
shareAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<ShareAlbumRequest,ShareAlbumResponse> shareAlbumCallable()
Marks an album as shared and accessible to other users. This action can only be performed on albums which were created by the developer via the API.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; ShareAlbumRequest request = ShareAlbumRequest.newBuilder() .setAlbumId(albumId) .build(); ApiFuture<ShareAlbumResponse> future = internalPhotosLibraryClient.shareAlbumCallable().futureCall(request); // Do something ShareAlbumResponse response = future.get(); }
-
listSharedAlbums
public final InternalPhotosLibraryClient.ListSharedAlbumsPagedResponse listSharedAlbums(boolean excludeNonAppCreatedData)
Lists all shared albums available in the Sharing tab of the user's Google Photos app.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { boolean excludeNonAppCreatedData = false; for (Album element : internalPhotosLibraryClient.listSharedAlbums(excludeNonAppCreatedData).iterateAll()) { // doThingsWith(element); } }
- Parameters:
excludeNonAppCreatedData
- If set, the results exclude media items that were not created by this app. Defaults to false (all albums are returned). This field is ignored if the photoslibrary.readonly.appcreateddata scope is used.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listSharedAlbums
public final InternalPhotosLibraryClient.ListSharedAlbumsPagedResponse listSharedAlbums(ListSharedAlbumsRequest request)
Lists all shared albums available in the Sharing tab of the user's Google Photos app.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListSharedAlbumsRequest request = ListSharedAlbumsRequest.newBuilder().build(); for (Album element : internalPhotosLibraryClient.listSharedAlbums(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
-
listSharedAlbumsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListSharedAlbumsRequest,InternalPhotosLibraryClient.ListSharedAlbumsPagedResponse> listSharedAlbumsPagedCallable()
Lists all shared albums available in the Sharing tab of the user's Google Photos app.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListSharedAlbumsRequest request = ListSharedAlbumsRequest.newBuilder().build(); ApiFuture<ListSharedAlbumsPagedResponse> future = internalPhotosLibraryClient.listSharedAlbumsPagedCallable().futureCall(request); // Do something for (Album element : future.get().iterateAll()) { // doThingsWith(element); } }
-
listSharedAlbumsCallable
public final com.google.api.gax.rpc.UnaryCallable<ListSharedAlbumsRequest,ListSharedAlbumsResponse> listSharedAlbumsCallable()
Lists all shared albums available in the Sharing tab of the user's Google Photos app.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { ListSharedAlbumsRequest request = ListSharedAlbumsRequest.newBuilder().build(); while (true) { ListSharedAlbumsResponse response = internalPhotosLibraryClient.listSharedAlbumsCallable().call(request); for (Album element : response.getSharedAlbumsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } }
-
unshareAlbum
public final UnshareAlbumResponse unshareAlbum(java.lang.String albumId)
Marks a previously shared album as private. This means that the album is no longer shared and all the non-owners will lose access to the album. All non-owner content will be removed from the album. If a non-owner has previously added the album to their library, they will retain all photos in their library. This action can only be performed on albums which were created by the developer via the API.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; UnshareAlbumResponse response = internalPhotosLibraryClient.unshareAlbum(albumId); }
- Parameters:
albumId
- Identifier of the album to be unshared. This album id must belong to an album created by the developer.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
unshareAlbum
public final UnshareAlbumResponse unshareAlbum(UnshareAlbumRequest request)
Marks a previously shared album as private. This means that the album is no longer shared and all the non-owners will lose access to the album. All non-owner content will be removed from the album. If a non-owner has previously added the album to their library, they will retain all photos in their library. This action can only be performed on albums which were created by the developer via the API.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; UnshareAlbumRequest request = UnshareAlbumRequest.newBuilder() .setAlbumId(albumId) .build(); UnshareAlbumResponse response = internalPhotosLibraryClient.unshareAlbum(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
-
unshareAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<UnshareAlbumRequest,UnshareAlbumResponse> unshareAlbumCallable()
Marks a previously shared album as private. This means that the album is no longer shared and all the non-owners will lose access to the album. All non-owner content will be removed from the album. If a non-owner has previously added the album to their library, they will retain all photos in their library. This action can only be performed on albums which were created by the developer via the API.Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; UnshareAlbumRequest request = UnshareAlbumRequest.newBuilder() .setAlbumId(albumId) .build(); ApiFuture<UnshareAlbumResponse> future = internalPhotosLibraryClient.unshareAlbumCallable().futureCall(request); // Do something UnshareAlbumResponse response = future.get(); }
-
batchRemoveMediaItemsFromAlbum
public final BatchRemoveMediaItemsFromAlbumResponse batchRemoveMediaItemsFromAlbum(java.lang.String albumId, java.util.List<java.lang.String> mediaItemIds)
Removes one or more media items from a specified album. The media items and the album must have been created by the developer via the API.For albums that are shared, this action is only supported for media items that were added to the album by this user, or for all media items if the album was created by this user.
Partial success is not supported. The entire request will fail and no action will be performed on the album if an invalid media item or album is specified.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; List<String> mediaItemIds = new ArrayList<>(); BatchRemoveMediaItemsFromAlbumResponse response = internalPhotosLibraryClient.batchRemoveMediaItemsFromAlbum(albumId, mediaItemIds); }
- Parameters:
albumId
- Identifier of the [Album][google.photos.types.Album] that the media items are to be removed from.mediaItemIds
- Identifiers of the [MediaItem][google.photos.types.MediaItem]s to be removed.Must not contain repeated identifiers and cannot be empty. The maximum number of media items that can be removed in one call is 50.
- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
batchRemoveMediaItemsFromAlbum
public final BatchRemoveMediaItemsFromAlbumResponse batchRemoveMediaItemsFromAlbum(BatchRemoveMediaItemsFromAlbumRequest request)
Removes one or more media items from a specified album. The media items and the album must have been created by the developer via the API.For albums that are shared, this action is only supported for media items that were added to the album by this user, or for all media items if the album was created by this user.
Partial success is not supported. The entire request will fail and no action will be performed on the album if an invalid media item or album is specified.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; List<String> mediaItemIds = new ArrayList<>(); BatchRemoveMediaItemsFromAlbumRequest request = BatchRemoveMediaItemsFromAlbumRequest.newBuilder() .setAlbumId(albumId) .addAllMediaItemIds(mediaItemIds) .build(); BatchRemoveMediaItemsFromAlbumResponse response = internalPhotosLibraryClient.batchRemoveMediaItemsFromAlbum(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
-
batchRemoveMediaItemsFromAlbumCallable
public final com.google.api.gax.rpc.UnaryCallable<BatchRemoveMediaItemsFromAlbumRequest,BatchRemoveMediaItemsFromAlbumResponse> batchRemoveMediaItemsFromAlbumCallable()
Removes one or more media items from a specified album. The media items and the album must have been created by the developer via the API.For albums that are shared, this action is only supported for media items that were added to the album by this user, or for all media items if the album was created by this user.
Partial success is not supported. The entire request will fail and no action will be performed on the album if an invalid media item or album is specified.
Sample code:
try (InternalPhotosLibraryClient internalPhotosLibraryClient = InternalPhotosLibraryClient.create()) { String albumId = ""; List<String> mediaItemIds = new ArrayList<>(); BatchRemoveMediaItemsFromAlbumRequest request = BatchRemoveMediaItemsFromAlbumRequest.newBuilder() .setAlbumId(albumId) .addAllMediaItemIds(mediaItemIds) .build(); ApiFuture<BatchRemoveMediaItemsFromAlbumResponse> future = internalPhotosLibraryClient.batchRemoveMediaItemsFromAlbumCallable().futureCall(request); // Do something BatchRemoveMediaItemsFromAlbumResponse response = future.get(); }
-
close
public final void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
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, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
awaitTermination
in interfacecom.google.api.gax.core.BackgroundResource
- Throws:
java.lang.InterruptedException
-
-