gphotos

package module
v0.0.0-...-179e163 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 14 Imported by: 0

README

gphotos

日本語版はこちら

Installation

go get github.com/Q-Brains/gphotos

See GoDoc for further documentation.

Documentation

Overview

Package gphotos is a package that uses `Photos Library API` of `Google Photos APIs`. It corresponds to each method of Reference (https://developers.google.com/photos/library/reference/rest).

Authorization

API Refercence (https://developers.google.com/photos/library/guides/authentication-authorization) Q-Brains/gphotos instance (https://godoc.org/github.com/Q-Brains/gphotos#Auth)

Resource: albums

API Refercence (https://developers.google.com/photos/library/reference/rest/v1/albums) Q-Brains/gphotos instance (https://godoc.org/github.com/Q-Brains/gphotos#Albums)

Resource: mediaItems

API Refercence (https://developers.google.com/photos/library/reference/rest/v1/mediaItems) Q-Brains/gphotos instance (https://godoc.org/github.com/Q-Brains/gphotos#MediaItems)

Resource: sharedAlbums

API Refercence (https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums) Q-Brains/gphotos instance (https://godoc.org/github.com/Q-Brains/gphotos#SharedAlbums)

Uploading media

API Refercence (https://developers.google.com/photos/library/guides/upload-media) Q-Brains/gphotos instance (https://godoc.org/github.com/Q-Brains/gphotos#UploadingMedia)

Customize Uploader

Q-Brains/gphotos instance (https://godoc.org/github.com/Q-Brains/gphotos#Uploader)

Index

Constants

View Source
const (
	// Read access only.
	// List items from the library and all albums, access all media items and list albums owned by the user, including those which have been shared with them.
	// For albums shared by the user, share properties are only returned if the .sharing scope has also been granted.
	// The ShareInfo property for albums and the contributorInfo for mediaItems is only available if the .sharing scope has also been granted.
	// For more information, see Share media.
	Readonly authorizationScope = "https://www.googleapis.com/auth/photoslibrary.readonly"

	// Write access only.
	// Acess to upload bytes, create media items, create albums, and add enrichments. Only allows new media to be created in the user's library and in albums created by the app.
	Appendonly = "https://www.googleapis.com/auth/photoslibrary.appendonly"

	// Read access to media items and albums created by the developer. For more information, see Access media items and List library contents, albums, and media items.
	// Intended to be requested together with the Appendonly scope.
	Appcreateddata = "https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata"

	// Access to both the Appendonly and Readonly scopes. Doesn't include Sharing.
	ReadAndAppend = "https://www.googleapis.com/auth/photoslibrary"

	// Access to sharing calls.
	// Access to create an album, share it, upload media items to it, and join a shared album.
	Sharing = "https://www.googleapis.com/auth/photoslibrary.sharing"
)

Here's the authorization scopes. Source: https://developers.google.com/photos/library/guides/authentication-authorization#OAuth2Authorizing

Variables

This section is empty.

Functions

func RequestError

func RequestError(resp *http.Response) error

RequestError receives an error and displays an ErrorResponse.

Types

type Album

type Album struct {
	ID                    string      `json:"id,omitempty"`
	Title                 string      `json:"title,omitempty"`
	ProductURL            string      `json:"productUrl,omitempty"`
	IsWriteable           bool        `json:"isWriteable,omitempty"`
	ShareInfo             ShareInfo   `json:"shareInfo,omitempty"`
	MediaItemsCount       json.Number `json:"mediaItemsCount,omitempty"`
	CoverPhotoBaseURL     string      `json:"coverPhotoBaseUrl,omitempty"`
	CoverPhotoMediaItemID string      `json:"coverPhotoMediaItemId,omitempty"`
}

Album represents an album in Google Photos. Source: https://developers.google.com/photos/library/reference/rest/v1/albums#resource:-album

type AlbumPosition

type AlbumPosition struct {
	Position                 PositionType `json:"position,omitempty"`
	RelativeMediaItemID      string       `json:"relativeMediaItemId,omitempty"`
	RelativeEnrichmentItemID string       `json:"relativeEnrichmentItemId,omitempty"`
}

AlbumPosition represents a specified position in an album. Source: https://developers.google.com/photos/library/reference/rest/v1/AlbumPosition

type AlbumsAddEnrichmentRequest

type AlbumsAddEnrichmentRequest struct {
	NewEnrichmentItem NewEnrichmentItem `json:"newEnrichmentItem,omitempty"`
	AlbumPosition     AlbumPosition     `json:"albumPosition,omitempty"`
}

AlbumsAddEnrichmentRequest is a required body of the Albums.AddEnrichment method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#request-body

type AlbumsAddEnrichmentResponse

type AlbumsAddEnrichmentResponse struct {
	EnrichmentItem EnrichmentItem `json:"enrichmentItem,omitempty"`
}

AlbumsAddEnrichmentResponse is the body returned by the Albums.AddEnrichment method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#response-body

type AlbumsBatchAddMediaItemsRequest

type AlbumsBatchAddMediaItemsRequest struct {
	MediaItemIDs []string `json:"mediaItemIds,omitempty"`
}

AlbumsBatchAddMediaItemsRequest is a required body of the Albums.AddMediaItems method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/batchAddMediaItems#request-body

type AlbumsBatchRemoveMediaItemsRequest

type AlbumsBatchRemoveMediaItemsRequest struct {
	MediaItemIDs []string `json:"mediaItemIds,omitempty"`
}

AlbumsBatchRemoveMediaItemsRequest is a required body of Albums.BatchRemoveMediaItems method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/batchRemoveMediaItems#request-body

type AlbumsCreateRequest

type AlbumsCreateRequest struct {
	Album Album `json:"album,omitempty"`
}

AlbumsCreateRequest is a required body of Albums.Create method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/batchRemoveMediaItems#request-body

type AlbumsCreateResponse

type AlbumsCreateResponse Album

AlbumsCreateResponse is the body returned by the Albums.Create method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/batchRemoveMediaItems#response-body

type AlbumsGetResponse

type AlbumsGetResponse Album

AlbumsGetResponse is the body returned by the Albums.Get method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/get#response-body

type AlbumsListResponse

type AlbumsListResponse struct {
	Albums        []Album `json:"albums,omitempty"`
	NextPageToken string  `json:"nextPageToken,omitempty"`
}

AlbumsListResponse is the body returned by the Albums.List method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/list#response-body

type AlbumsRequests

type AlbumsRequests interface {

	// AddEnrichment is a method that adds an enrichment at a specified position in a defined album.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment
	AddEnrichment(client *http.Client, albumID string, request AlbumsAddEnrichmentRequest) (AlbumsAddEnrichmentResponse, error)

	// BatchAddMediaItems is a method that adds one or more media items in a user's Google Photos library to an album.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/albums/batchAddMediaItems
	BatchAddMediaItems(client *http.Client, albumID string, request AlbumsBatchAddMediaItemsRequest) error

	// BatchRemoveMediaItems is a method that removes one or more media items from a specified album.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/albums/batchRemoveMediaItems
	BatchRemoveMediaItems(client *http.Client, albumID string, request AlbumsBatchRemoveMediaItemsRequest) error

	// Create is a method that creates an album in a user's Google Photos library.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/albums/create
	Create(client *http.Client, request AlbumsCreateRequest) (AlbumsCreateResponse, error)

	// Get is a method that returns the album based on the specified `albumId`.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/albums/get
	Get(client *http.Client, albumID string) (AlbumsGetResponse, error)

	// List is a method that lists all albums shown to a user in the Albums tab of the Google Photos app.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/albums/list
	List(client *http.Client, queries ...ListQuery) (AlbumsListResponse, error)

	// Share is a method that marks an album as shared and accessible to other users.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/albums/share
	Share(client *http.Client, albumID string, request AlbumsShareRequest) (AlbumsShareResponse, error)

	// Unshare is a method that marks a previously shared album as private.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/albums/unshare
	Unshare(client *http.Client, albumID string) error
	// contains filtered or unexported methods
}

AlbumsRequests is a collection of requests methods belonging to `albums`. The only instance of AlbumsRequests is Albums(https://godoc.org/github.com/Q-Brains/gphotos#Albums). Source: https://developers.google.com/photos/library/reference/rest/v1/albums

var Albums AlbumsRequests = albumsRequests{}

Albums is the only instance of AlbumsRequests(https://godoc.org/github.com/Q-Brains/gphotos#AlbumsRequests).

type AlbumsShareRequest

type AlbumsShareRequest struct {
	SharedAlbumOptions SharedAlbumOptions `json:"sharedAlbumOptions,omitempty"`
}

AlbumsShareRequest is a required body of Albums.Share method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/share#request-body

type AlbumsShareResponse

type AlbumsShareResponse struct {
	ShareInfo ShareInfo `json:"shareInfo,omitempty"`
}

AlbumsShareResponse is the body returned by the Albums.Share method. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/share#response-body

type AuthorizationScopes

type AuthorizationScopes []authorizationScope

AuthorizationScopes represents the authentication scope of PhotosLibraryAPI.

type Authorizations

type Authorizations interface {
	// OAuth2InteractiveFlow is a method that performs OAuth2 authentication of GooglePhotos interactivity.
	// Because it uses standard input, it cannot be used in automation systems.
	OAuth2InteractiveFlow(clientID string, clientSecret string, scopes AuthorizationScopes, state string, options ...oauth2.AuthCodeOption) (*http.Client, error)

	// OAuth2Config is a method that creates the config of "golang.org/x/oauth2".
	// Using this method eliminates the need to import "golang.org/x/oauth2".
	OAuth2Config(clientID string, clientSecret string, scopes AuthorizationScopes) oauth2.Config

	// OAuth2CreateURL is a method that creates OAuth2 authorization URL.
	OAuth2CreateURL(conf oauth2.Config, state string, options ...oauth2.AuthCodeOption) string

	// OAuth2CreateClient is a method that creates OAuth2 client from the config of "golang.org/x/oauth2" and authorization code.
	OAuth2CreateClient(conf oauth2.Config, authCode string) (*http.Client, error)
}

Authorizations is a collection of authentication methods. The only instance of Authorizations is Auth(https://godoc.org/github.com/Q-Brains/gphotos#Auth). However, PhotosLibraryAPI can only be authenticated with OAuth2 authentication.

var Auth Authorizations = authorizations{}

Auth is the only instance of Authorizations(https://godoc.org/github.com/Q-Brains/gphotos#Authorizations).

type ContentCategory

type ContentCategory int

ContentCategory represents a set of pre-defined content categories that you can filter on. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#contentcategory

const (
	// Default content category. This category is ignored when any other category is used in the filter.
	ContentCategoryNone ContentCategory = iota

	// Media items containing landscapes.
	Landscapes

	// Media items containing receipts.
	Receipts

	// Media items containing cityscapes.
	Cityscapes

	// Media items containing landmarks.
	Landmarks

	// Media items that are selfies.
	Selfies

	// Media items containing people.
	People

	// Media items containing pets.
	Pets

	// Media items from weddings.
	Weddings

	// Media items from birthdays.
	Birthdays

	// Media items containing documents.
	Documents

	// Media items taken during travel.
	Travel

	// Media items containing animals.
	Animals

	// Media items containing food.
	Food

	// Media items from sporting events.
	Sport

	// Media items taken at night.
	Night

	// Media items from performances.
	Performances

	// Media items containing whiteboards.
	Whiteboards

	// Media items that are screenshots.
	Screenshots

	// Media items that are considered to be utility.
	// These include, but aren't limited to documents, screenshots, whiteboards etc.
	Utility

	// Media items containing art.
	Arts

	// Media items containing crafts.
	Crafts

	// Media items related to fashion.
	Fashion

	// Media items containing houses.
	Houses

	// Media items containing gardens.
	Gardens

	// Media items containing flowers.
	Flowers

	// Media items taken of holidays.
	Holidays
)

This is a set of pre-defined content categories that you can filter on.

type ContentFilter

type ContentFilter struct {
	IncludedContentCategories ContentCategory `json:"includedContentCategories,omitempty"`
	ExcludedContentCategories ContentCategory `json:"excludedContentCategories,omitempty"`
}

ContentFilter represents the media item returned based on the content type. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#contentfilter

type ContributorInfo

type ContributorInfo struct {
	ProfilePictureBaseURL string `json:"profilePictureBaseUrl,omitempty"`
	DisplayName           string `json:"displayName,omitempty"`
}

ContributorInfo represents information about the user who added the media item. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems#contributorinfo

type Date

type Date struct {
	Year  int `json:"year,omitempty"`
	Month int `json:"month,omitempty"`
	Day   int `json:"day,omitempty"`
}

Date represents a whole calender date. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#date

type DateFilter

type DateFilter struct {
	Dates  []Date      `json:"dates,omitempty"`
	Ranges []DateRange `json:"ranges,omitempty"`
}

DateFilter represents the allowed dates or date ranges for the media returned. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#datefilter

type DateRange

type DateRange struct {
	StartDate Date `json:"startDate,omitempty"`
	EndDate   Date `json:"endDate,omitempty"`
}

DateRange represents a range of dates. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#daterange

type EnrichmentItem

type EnrichmentItem struct {
	ID string `json:"id,omitempty"`
}

EnrichmentItem represents an enrichment item. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#enrichmentitem

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Code    json.Number `json:"code,omitempty"`
		Message string      `json:"message,omitempty"`
		Status  string      `json:"status,omitempty"`
	} `json:"error,omitempty"`
}

ErrorResponse represents an error condition.

type Feature

type Feature int

Feature represents the set of features that you can filter on. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#feature

const (
	// Treated as if no filters are applied. All features are included.
	FeatureNone Feature = iota

	// Media items that the user has marked as favorites in the Google Photos app.
	Favorites
)

The set of features that you can filter on.

type FeatureFilter

type FeatureFilter struct {
	IncludedFeatures Feature `json:"includedFeatures,omitempty"`
}

FeatureFilter represents the features that the media items should have. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#featurefilter

type Filters

type Filters struct {
	DateFilter               DateFilter      `json:"dateFilter,omitempty"`
	ContentFilter            ContentFilter   `json:"contentFilter,omitempty"`
	MediaTypeFilter          MediaTypeFilter `json:"mediaTypeFilter,omitempty"`
	FeatureFilter            FeatureFilter   `json:"featureFilter,omitempty"`
	IncludeArchivedMedia     bool            `json:"includeArchivedMedia,omitempty"`
	ExcludeNonAppCreatedData bool            `json:"excludeNonAppCreatedData,omitempty"`
}

Filters that can be applied to a media item search. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#filters

type LatLng

type LatLng struct {
	Latitude  int `json:"latitude,omitempty"`
	Longitude int `json:"longitude,omitempty"`
}

LatLng represents a latitude/longitude pair. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#latlng

type ListQuery

type ListQuery func(*url.Values)

ListQuery is a structure for using variable length arguments in Albums.List, MediaItems.List and SharedAlbums.List.

func ExcludeNonAppCreatedData

func ExcludeNonAppCreatedData(flag bool) ListQuery

ExcludeNonAppCreatedData is a function to pass a boolean value to whether to exclude the value created by App to Albums.List, MediaItems.List and SharedAlbums.List.

func PageSize

func PageSize(size int) ListQuery

PageSize is a function for passing a page size query to Albums.List, MediaItems.List and SharedAlbums.List.

func PageToken

func PageToken(token string) ListQuery

PageToken is a function for passing a page token query to Albums.List, MediaItems.List and SharedAlbums.List.

type Location

type Location struct {
	LocationName string `json:"locationName,omitempty"`
	Latlng       LatLng `json:"latlng,omitempty"`
}

Location represents a physical location. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#location

type LocationEnrichment

type LocationEnrichment struct {
	Location Location `json:"location,omitempty"`
}

LocationEnrichment represents an enrichment containing a single location. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#locationenrichment

type MapEnrichment

type MapEnrichment struct {
	Origin      Location `json:"origin,omitempty"`
	Destination Location `json:"destination,omitempty"`
}

MapEnrichment represents an enrichment containing a map, showing origin and destination locations. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#mapenrichment

type MediaItem

type MediaItem struct {
	ID              string          `json:"id,omitempty"`
	Description     string          `json:"description,omitempty"`
	ProductURL      string          `json:"productUrl,omitempty"`
	BaseURL         string          `json:"baseUrl,omitempty"`
	MimeType        string          `json:"mimeType,omitempty"`
	MediaMetadata   MediaMetadata   `json:"mediaMetadata,omitempty"`
	ContributorInfo ContributorInfo `json:"contributorInfo,omitempty"`
	Filename        string          `json:"filename,omitempty"`
}

MediaItem represents a media item (such as a photo or video) in Google Photos. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems#resource:-mediaitem

type MediaItemResult

type MediaItemResult struct {
	Status    Status    `json:"status,omitempty"`
	MediaItem MediaItem `json:"mediaItem,omitempty"`
}

MediaItemResult represents result of retrieving a media item. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchGet#mediaitemresult

type MediaItemsBatchCreateRequest

type MediaItemsBatchCreateRequest struct {
	AlbumID       string         `json:"albumId,omitempty"`
	NewMediaItems []NewMediaItem `json:"newMediaItems,omitempty"`
	AlbumPosition AlbumPosition  `json:"albumPosition,omitempty"`
}

MediaItemsBatchCreateRequest is a required body of the MediaItems.BatchCreate method. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#request-body

type MediaItemsBatchCreateResponse

type MediaItemsBatchCreateResponse struct {
	NewMediaItemResults []NewMediaItemResult `json:"newMediaItemResults,omitempty"`
}

MediaItemsBatchCreateResponse is the body returned by the MediaItems.BatchCreate method. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#response-body

type MediaItemsBatchGetQuery

type MediaItemsBatchGetQuery func(*url.Values)

MediaItemsBatchGetQuery is a structure for using variable length arguments in MediaItems.BatchGet.

func MediaItemIDs

func MediaItemIDs(ids string) MediaItemsBatchGetQuery

MediaItemIDs is a function for passing media item indexes query to MediaItems.BatchGet.

type MediaItemsBatchGetResponse

type MediaItemsBatchGetResponse struct {
	MediaItemResults []MediaItemResult `json:"mediaItemResults,omitempty"`
}

MediaItemsBatchGetResponse is the body returned by the MediaItems.BatchGet method. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchGet#response-body

type MediaItemsGetResponse

type MediaItemsGetResponse MediaItem

MediaItemsGetResponse is the body returned by the MediaItems.Get method. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/get#response-body

type MediaItemsListResponse

type MediaItemsListResponse struct {
	MediaItems    []MediaItem `json:"mediaItems,omitempty"`
	NextPageToken string      `json:"nextPageToken,omitempty"`
}

MediaItemsListResponse is the body returned by the MediaItems.BatchGet method. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/list#response-body

type MediaItemsRequests

type MediaItemsRequests interface {

	// BatchCreate is a method that creates one or more media items in a user's Google Photos library.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate
	BatchCreate(client *http.Client, request MediaItemsBatchCreateRequest) (MediaItemsBatchCreateResponse, error)

	// BatchGet is a method that returns the list of media items for the specified media item identifiers.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchGet
	BatchGet(client *http.Client, queries ...MediaItemsBatchGetQuery) (MediaItemsBatchGetResponse, error)

	// Get is a method that returns the media item for the specified media item identifier.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/get
	Get(client *http.Client, mediaItemID string) (MediaItemsGetResponse, error)

	// List is a method that list all media items from a user's Google Photos library.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/list
	List(client *http.Client, queries ...ListQuery) (MediaItemsListResponse, error)

	// Search is a method that searches for media items in a user's Google Photos library.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search
	Search(client *http.Client, request MediaItemsSearchRequest) (MediaItemsSearchResponse, error)
	// contains filtered or unexported methods
}

MediaItemsRequests is a collection of request methods belonging to `mediaItems`. The only instance of MediaItemsRequests is MediaItems(https://godoc.org/github.com/Q-Brains/gphotos#MediaItems). Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems

var MediaItems MediaItemsRequests = mediaItemsRequests{}

MediaItems is the only instance of MediaItemsRequests(https://godoc.org/github.com/Q-Brains/gphotos#MediaItemsRequests).

type MediaItemsSearchRequest

type MediaItemsSearchRequest struct {
	AlbumID   string  `json:"albumId,omitempty"`
	PageSize  int     `json:"pageSize,omitempty"`
	PageToken string  `json:"pageToken,omitempty"`
	Filters   Filters `json:"filters,omitempty"`
}

MediaItemsSearchRequest is a required body of the MediaItems.Search method. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#request-body

type MediaItemsSearchResponse

type MediaItemsSearchResponse struct {
	MediaItems    []MediaItem `json:"mediaItems,omitempty"`
	NextPageToken string      `json:"nextPageToken,omitempty"`
}

MediaItemsSearchResponse is the body returned by the MediaItems.BatchGet method. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#response-body

type MediaMetadata

type MediaMetadata struct {
	CreationTime string `json:"creationTime,omitempty"`
	Width        string `json:"width,omitempty"`
	Height       string `json:"height,omitempty"`
	Photo        Photo  `json:"photo,omitempty"`
	Video        Video  `json:"video,omitempty"`
}

MediaMetadata represents metadata for a media item. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems#mediametadata

type MediaType

type MediaType int

MediaType represents the set of media types that can be searched for. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#mediatype

const (
	// Treated as if no filters are applied. All media types are included.
	AllMedia MediaType = iota

	// All media items that are considered videos.
	// This also includes movies the user has created using the Google Photos app.
	VideoType

	// All media items that are considered photos.
	// This includes .bmp, .gif, .ico, .jpg (and other spellings), .tiff, .webp and special photo types such as iOS live photos, Android motion photos, panoramas, photospheres.
	PhotoType
)

The set of media types that can be searched for.

type MediaTypeFilter

type MediaTypeFilter struct {
	MediaTypes MediaType `json:"mediaTypes,omitempty"`
}

MediaTypeFilter represents the type of media items to be returned, for example, videos or photos. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#mediatypefilter

type NewEnrichmentItem

type NewEnrichmentItem struct {
	TextEnrichment     TextEnrichment     `json:"textEnrichment,omitempty"`
	LocationEnrichment LocationEnrichment `json:"locationEnrichment,omitempty"`
	MapEnrichment      MapEnrichment      `json:"mapEnrichment,omitempty"`
}

NewEnrichmentItem represents a new enrichment item to be added to an album. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#newenrichmentitem

type NewMediaItem

type NewMediaItem struct {
	Description     string          `json:"description,omitempty"`
	SimpleMediaItem SimpleMediaItem `json:"simpleMediaItem,omitempty"`
}

NewMediaItem represents new media item that's created in a user's Google Photos account. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#newmediaitem

type NewMediaItemResult

type NewMediaItemResult struct {
	UploadToken string    `json:"uploadToken,omitempty"`
	Status      Status    `json:"status,omitempty"`
	MediaItem   MediaItem `json:"mediaItem,omitempty"`
}

NewMediaItemResult represents result of creating a new media item. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#newmediaitemresult

type Photo

type Photo struct {
	CameraMake      string `json:"cameraMake,omitempty"`
	CameraModel     string `json:"cameraModel,omitempty"`
	FocalLength     int    `json:"focalLength,omitempty"`
	ApertureFNumber int    `json:"apertureFNumber,omitempty"`
	ISOEquivalent   int    `json:"isoEquivalent,omitempty"`
	ExposureTime    string `json:"exposureTime,omitempty"`
}

Photo represents metadata that is specific to a photo, such as, ISO, focal length and exposure time. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems#photo

type PositionType

type PositionType int

PositionType represents possible positions in an album. Source: https://developers.google.com/photos/library/reference/rest/v1/AlbumPosition#positiontype

const (
	// Default value if this enum isn't set.
	PositionTypeUnspecified PositionType = iota

	// At the beginning of the album.
	FirstInAlbum

	// At the end of the album.
	LastInAlbum

	// After a media item.
	AfterMediaItem

	// After an enrichment item.
	AfterEnrichmentItem
)

Possible positions in an album.

type ShareInfo

type ShareInfo struct {
	SharedAlbumOptions SharedAlbumOptions `json:"sharedAlbumOptions,omitempty"`
	ShareableURL       string             `json:"shareableUrl,omitempty"`
	ShareToken         string             `json:"shareToken,omitempty"`
	IsJoined           bool               `json:"isJoined,omitempty"`
	IsOwned            bool               `json:"isOwned,omitempty"`
}

ShareInfo represents information about albums that are shared. Source: https://developers.google.com/photos/library/reference/rest/v1/albums#shareinfo

type SharedAlbumOptions

type SharedAlbumOptions struct {
	IsCollaborative bool `json:"isCollaborative,omitempty"`
	IsCommentable   bool `json:"isCommentable,omitempty"`
}

SharedAlbumOptions represents options that control the sharing of an album. Source: https://developers.google.com/photos/library/reference/rest/v1/albums#sharedalbumoptions

type SharedAlbumsGetResponse

type SharedAlbumsGetResponse Album

SharedAlbumsGetResponse is the body returned by the SharedAlbums.Get method. Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/get#response-body

type SharedAlbumsJoinRequest

type SharedAlbumsJoinRequest struct {
	ShareToken string `json:"shareToken,omitempty"`
}

SharedAlbumsJoinRequest is a required body of the SharedAlbums.Join method. Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/join#request-body

type SharedAlbumsJoinResponse

type SharedAlbumsJoinResponse struct {
	Album Album `json:"album,omitempty"`
}

SharedAlbumsJoinResponse is the body returned by the SharedAlbums.Join method. Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/join#response-body

type SharedAlbumsLeaveRequest

type SharedAlbumsLeaveRequest struct {
	ShareToken string `json:"shareToken,omitempty"`
}

SharedAlbumsLeaveRequest is a required body of the SharedAlbums.Leave method. Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/leave#request-body

type SharedAlbumsListResponse

type SharedAlbumsListResponse struct {
	SharedAlbums  []Album `json:"sharedAlbums,omitempty"`
	NextPageToken string  `json:"nextPageToken,omitempty"`
}

SharedAlbumsListResponse is the body returned by the SharedAlbums.List method. Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/list#response-body

type SharedAlbumsRequests

type SharedAlbumsRequests interface {

	// Get is a method that returns the album based on the specified `shareToken`.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/get
	Get(client *http.Client, shareToken string) (SharedAlbumsGetResponse, error)

	// Join is a method that joins a shared album on behalf of the Google Photos user.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/join
	Join(client *http.Client, request SharedAlbumsJoinRequest) (SharedAlbumsJoinResponse, error)

	// Leave is a method that leaves a previously-joined shared album on behalf of the Google Photos user.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/leave
	Leave(client *http.Client, request SharedAlbumsLeaveRequest) error

	// List is a method that lists all shared albums available in the Sharing tab of the user's Google Photos app.
	// Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums/list
	List(client *http.Client, queries ...ListQuery) (SharedAlbumsListResponse, error)
	// contains filtered or unexported methods
}

SharedAlbumsRequests is a collection of request methods belonging to `sharedAlbums`. The only instance of SharedAlbumsRequests is SharedAlbums(https://godoc.org/github.com/Q-Brains/gphotos#SharedAlbums). Source: https://developers.google.com/photos/library/reference/rest/v1/sharedAlbums

var SharedAlbums SharedAlbumsRequests = sharedAlbumsRequests{}

SharedAlbums is the only instance of SharedAlbumsRequests(https://godoc.org/github.com/Q-Brains/gphotos#SharedAlbumsRequests).

type SimpleMediaItem

type SimpleMediaItem struct {
	UploadToken string `json:"uploadToken,omitempty"`
}

SimpleMediaItem represents a simple media item to be created in Google Photos via an upload token. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate#simplemediaitem

type Status

type Status struct {
	Code    int               `json:"code,omitempty"`
	Message string            `json:"message,omitempty"`
	Details map[string]string `json:"details,omitempty"`
}

Status represents a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. Source: https://developers.google.com/photos/library/reference/rest/v1/Status

type TextEnrichment

type TextEnrichment struct {
	Text string `json:"text,omitempty"`
}

TextEnrichment represents an enrichment containing text. Source: https://developers.google.com/photos/library/reference/rest/v1/albums/addEnrichment#textenrichment

type UploadMethods

type UploadMethods interface {
	// Upload is a method to upload MediaItems to GooglePhotos.
	// Use UploadWithAlbum or UploadWithAlbumname if you want to add these MediaItems to album at the same time as upload.
	Upload(client *http.Client, filePaths []string) ([]MediaItem, error)

	// UploadWithAlbum is a method to upload MediaItems to GooglePhotos with it added to the Album.
	UploadWithAlbum(client *http.Client, filePaths []string, album Album) ([]MediaItem, error)

	// UploadWithAlbumname is a method to upload MediaItems to GooglePhotos with it added to a specific name Album.
	// If the Album does not exist in GooglePhotos, it will be created.
	UploadWithAlbumname(client *http.Client, filePaths []string, albumname string) (Album, []MediaItem, error)
}

UploadMethods is a collection of customized upload methods. The only instance of UploadMethods is UploadMethods(https://godoc.org/github.com/Q-Brains/gphotos#UploadMethods).

var Uploader UploadMethods = uploadMethods{}

Uploader is the only instance of UploadMethods(https://godoc.org/github.com/Q-Brains/gphotos#UploadMethods).

type UploadingMediaRequests

type UploadingMediaRequests interface {

	// UploadMedia is a method that uploads media items to a user’s library or album.
	// Source: https://developers.google.com/photos/library/guides/upload-media
	UploadMedia(client *http.Client, filePath string, filename string) (uploadToken string, err error)

	// ResumableUploads is a method.
	// Source: https://developers.google.com/photos/library/guides/resumable-uploads
	ResumableUploads(client *http.Client, filePath string, filename string) (uploadToken string, err error)
	// contains filtered or unexported methods
}

UploadingMediaRequests is a collection of request methods belonging to `UploadingMedia`. The only instance of UploadMediaRequests is UploadMedia(https://godoc.org/github.com/Q-Brains/gphotos#UploadMedia). Source: https://developers.google.com/photos/library/guides/overview

var UploadingMedia UploadingMediaRequests = uploadingMediaRequests{}

UploadingMedia is the only instance of UploadingMediaRequests(https://godoc.org/github.com/Q-Brains/gphotos#UploadMediaRequests).

type Video

type Video struct {
	CameraMake  string                `json:"cameraMake,omitempty"`
	CameraModel string                `json:"cameraModel,omitempty"`
	FPS         int                   `json:"fps,omitempty"`
	Status      VideoProcessingStatus `json:"status,omitempty"`
}

Video represents metadata that is specific to a video, for example, fps and processing status. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems#video

type VideoProcessingStatus

type VideoProcessingStatus int

VideoProcessingStatus represents processing status of a video being uploaded to Google Photos. Source: https://developers.google.com/photos/library/reference/rest/v1/mediaItems#videoprocessingstatus

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL