immich

package
v0.25.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UploadCreated   = "created"
	UploadReplaced  = "replaced"
	UploadDuplicate = "duplicate"
)
View Source
const (
	StatusCreated   = "created"
	StatusReplaced  = "replaced"
	StatusDuplicate = "duplicate"
)
View Source
const (
	EndPointGetJobs                = "GetJobs"
	EndPointSendJobCommand         = "SendJobCommand"
	EndPointCreateJob              = "CreateJob"
	EndPointGetAllAlbums           = "GetAllAlbums"
	EndPointGetAlbumInfo           = "GetAlbumInfo"
	EndPointAddAsstToAlbum         = "AddAssetToAlbum"
	EndPointCreateAlbum            = "CreateAlbum"
	EndPointGetAssetAlbums         = "GetAssetAlbums"
	EndPointDeleteAlbum            = "DeleteAlbum"
	EndPointPingServer             = "PingServer"
	EndPointValidateConnection     = "ValidateConnection"
	EndPointGetServerStatistics    = "GetServerStatistics"
	EndPointGetAssetStatistics     = "GetAssetStatistics"
	EndPointGetSupportedMediaTypes = "GetSupportedMediaTypes"
	EndPointGetAllAssets           = "GetAllAssets"
	EndPointUpsertTags             = "UpsertTags"
	EndPointTagAssets              = "TagAssets"
	EndPointBulkTagAssets          = "BulkTagAssets"
	EndPointGetAllTags             = "GetAllTags"
	EndPointAssetUpload            = "AssetUpload"
	EndPointAssetReplace           = "AssetReplace"
	EndPointGetAboutInfo           = "GetAboutInfo"
)
View Source
const (
	TimeFormat string = "2006-01-02T15:04:05Z"
)

Variables

This section is empty.

Functions

func AlbumsFromAlbumSimplified

func AlbumsFromAlbumSimplified(albums []AlbumSimplified) []assets.Album

func OptionConnectionTimeout

func OptionConnectionTimeout(d time.Duration) clientOption

func OptionDryRun

func OptionDryRun(dryRun bool) clientOption

func OptionVerifySSL

func OptionVerifySSL(verify bool) clientOption

Types

type AboutInfo added in v0.24.3

type AboutInfo struct {
	Version       string `json:"version"`
	VersionURL    string `json:"versionUrl"`
	Licensed      bool   `json:"licensed"`
	Build         string `json:"build"`
	BuildURL      string `json:"buildUrl"`
	BuildImage    string `json:"buildImage"`
	BuildImageURL string `json:"buildImageUrl"`
	Repository    string `json:"repository"`
	RepositoryURL string `json:"repositoryUrl"`
	SourceRef     string `json:"sourceRef"`
	SourceCommit  string `json:"sourceCommit"`
	SourceURL     string `json:"sourceUrl"`
	Nodejs        string `json:"nodejs"`
	Exiftool      string `json:"exiftool"`
	Ffmpeg        string `json:"ffmpeg"`
	Libvips       string `json:"libvips"`
	Imagemagick   string `json:"imagemagick"`
}

getAboutInfo

type AlbumContent

type AlbumContent struct {
	ID string `json:"id,omitempty"`
	// OwnerID                    string    `json:"ownerId"`
	AlbumName   string   `json:"albumName"`
	Description string   `json:"description"`
	Shared      bool     `json:"shared"`
	Assets      []*Asset `json:"assets,omitempty"`
	AssetIDs    []string `json:"assetIds,omitempty"`
}

type AlbumSimplified

type AlbumSimplified struct {
	ID          string `json:"id,omitempty"`
	AlbumName   string `json:"albumName"`
	Description string `json:"description,omitempty"`
	// OwnerID                    string    `json:"ownerId"`
	// CreatedAt                  time.Time `json:"createdAt"`
	// UpdatedAt                  time.Time `json:"updatedAt"`
	// AlbumThumbnailAssetID      string    `json:"albumThumbnailAssetId"`
	// SharedUsers                []string  `json:"sharedUsers"`
	// Owner                      User      `json:"owner"`
	// Shared                     bool      `json:"shared"`
	// AssetCount                 int       `json:"assetCount"`
	// LastModifiedAssetTimestamp time.Time `json:"lastModifiedAssetTimestamp"
	AssetIds []string `json:"assetIds,omitempty"`
}

type Asset

type Asset struct {
	ID               string            `json:"id"`
	DeviceAssetID    string            `json:"deviceAssetId"`
	OwnerID          string            `json:"ownerId"`
	DeviceID         string            `json:"deviceId"`
	Type             string            `json:"type"`
	OriginalPath     string            `json:"originalPath"`
	OriginalFileName string            `json:"originalFileName"`
	Resized          bool              `json:"resized"`
	Thumbhash        string            `json:"thumbhash"`
	FileCreatedAt    ImmichTime        `json:"fileCreatedAt"`
	FileModifiedAt   ImmichTime        `json:"fileModifiedAt"`
	UpdatedAt        ImmichTime        `json:"updatedAt"`
	IsFavorite       bool              `json:"isFavorite"`
	IsArchived       bool              `json:"isArchived"`
	IsTrashed        bool              `json:"isTrashed"`
	Duration         string            `json:"duration"`
	Rating           int               `json:"rating"`
	ExifInfo         ExifInfo          `json:"exifInfo"`
	LivePhotoVideoID string            `json:"livePhotoVideoId"`
	Checksum         string            `json:"checksum"`
	StackParentID    string            `json:"stackParentId"`
	Albums           []AlbumSimplified `json:"-"` // Albums that asset belong to
	Tags             []TagSimplified   `json:"tags"`
	LibraryID        string            `json:"libraryId,omitempty"`
}

immich Asset simplified

func (Asset) AsAsset

func (ia Asset) AsAsset() *assets.Asset

NewAssetFromImmich creates an assets.Asset from an immich.Asset.

type AssetResponse

type AssetResponse struct {
	ID     string `json:"id"`
	Status string `json:"status"`
}

type AssetSimplified

type AssetSimplified struct {
	ID            string `json:"id"`
	DeviceAssetID string `json:"deviceAssetId"`
}

immich Asset simplified

type ExifInfo

type ExifInfo struct {
	Make             string         `json:"make"`
	Model            string         `json:"model"`
	ExifImageWidth   int            `json:"exifImageWidth"`
	ExifImageHeight  int            `json:"exifImageHeight"`
	FileSizeInByte   int64          `json:"fileSizeInByte"`
	Orientation      string         `json:"orientation"`
	DateTimeOriginal ImmichExifTime `json:"dateTimeOriginal,omitempty"`
	// 	ModifyDate       time.Time `json:"modifyDate"`
	TimeZone string `json:"timeZone"`
	// LensModel        string    `json:"lensModel"`
	// 	FNumber          float64   `json:"fNumber"`
	// 	FocalLength      float64   `json:"focalLength"`
	// 	Iso              int       `json:"iso"`
	// 	ExposureTime     string    `json:"exposureTime"`
	Latitude  float64 `json:"latitude,omitempty"`
	Longitude float64 `json:"longitude,omitempty"`
	// 	City             string    `json:"city"`
	// 	State            string    `json:"state"`
	// 	Country          string    `json:"country"`
	Description string `json:"description"`
}

type GetAssetOptions

type GetAssetOptions struct {
	UserID        string
	IsFavorite    bool
	IsArchived    bool
	WithoutThumbs bool
	Skip          string
}

func (*GetAssetOptions) Values

func (o *GetAssetOptions) Values() url.Values

type ImmichAlbumInterface

type ImmichAlbumInterface interface {
	GetAllAlbums(ctx context.Context) ([]AlbumSimplified, error)
	GetAlbumInfo(ctx context.Context, id string, withoutAssets bool) (AlbumContent, error)
	CreateAlbum(
		ctx context.Context,
		tilte string,
		description string,
		ids []string,
	) (assets.Album, error)

	// GetAssetAlbums get all albums that an asset belongs to
	GetAssetAlbums(ctx context.Context, assetID string) ([]AlbumSimplified, error)
	DeleteAlbum(ctx context.Context, id string) error
}

type ImmichAssetInterface

type ImmichAssetInterface interface {
	GetAssetInfo(ctx context.Context, id string) (*Asset, error)
	DownloadAsset(ctx context.Context, id string) (io.ReadCloser, error)
	UpdateAsset(ctx context.Context, id string, param UpdAssetField) (*Asset, error)
	ReplaceAsset(ctx context.Context, ID string, la *assets.Asset) (AssetResponse, error)
	GetAllAssets(ctx context.Context) ([]*Asset, error)
	AddAssetToAlbum(context.Context, string, []string) ([]UpdateAlbumResult, error)
	UpdateAssets(
		ctx context.Context,
		IDs []string,
		isArchived bool,
		isFavorite bool,
		latitude float64,
		longitude float64,
		removeParent bool,
		stackParentID string,
	) error
	GetAllAssetsWithFilter(context.Context, *SearchMetadataQuery, func(*Asset) error) error
	GetAssetsByHash(ctx context.Context, hash string) ([]*Asset, error)
	GetAssetsByImageName(ctx context.Context, name string) ([]*Asset, error)

	AssetUpload(context.Context, *assets.Asset) (AssetResponse, error)
	DeleteAssets(context.Context, []string, bool) error
}

type ImmichClient

type ImmichClient struct {
	DeviceUUID   string        // Device
	Retries      int           // Number of attempts on 500 errors
	RetriesDelay time.Duration // Duration between retries
	// contains filtered or unexported fields
}

func NewImmichClient

func NewImmichClient(endPoint string, key string, options ...clientOption) (*ImmichClient, error)

Create a new ImmichClient

func (*ImmichClient) AddAssetToAlbum

func (ic *ImmichClient) AddAssetToAlbum(ctx context.Context, albumID string, assets []string) ([]UpdateAlbumResult, error)

func (*ImmichClient) AssetUpload

func (ic *ImmichClient) AssetUpload(ctx context.Context, la *assets.Asset) (AssetResponse, error)

func (*ImmichClient) BulkTagAssets

func (ic *ImmichClient) BulkTagAssets(
	ctx context.Context,
	tagIDs []string,
	assetIDs []string,
) (struct {
	Count int `json:"count"`
}, error,
)

func (*ImmichClient) CreateAlbum

func (ic *ImmichClient) CreateAlbum(ctx context.Context, name string, description string, assetsIDs []string) (assets.Album, error)

func (*ImmichClient) CreateJob

func (ic *ImmichClient) CreateJob(ctx context.Context, name JobName) error

func (*ImmichClient) CreateStack

func (ic *ImmichClient) CreateStack(ctx context.Context, ids []string) (string, error)

CreateStack create a stack with the given assets, the 1st asset is the cover, return the stack ID

func (*ImmichClient) DeleteAlbum

func (ic *ImmichClient) DeleteAlbum(ctx context.Context, id string) error

func (*ImmichClient) DeleteAssets

func (ic *ImmichClient) DeleteAssets(ctx context.Context, id []string, forceDelete bool) error

func (*ImmichClient) DownloadAsset

func (ic *ImmichClient) DownloadAsset(ctx context.Context, id string) (io.ReadCloser, error)

func (*ImmichClient) EnableAppTrace

func (ic *ImmichClient) EnableAppTrace(w io.Writer)

func (*ImmichClient) GetAboutInfo added in v0.24.3

func (ic *ImmichClient) GetAboutInfo(ctx context.Context) (AboutInfo, error)

func (*ImmichClient) GetAlbumInfo

func (ic *ImmichClient) GetAlbumInfo(ctx context.Context, id string, withoutAssets bool) (AlbumContent, error)

func (*ImmichClient) GetAllAlbums

func (ic *ImmichClient) GetAllAlbums(ctx context.Context) ([]AlbumSimplified, error)

func (*ImmichClient) GetAllAssets

func (ic *ImmichClient) GetAllAssets(ctx context.Context) ([]*Asset, error)

func (*ImmichClient) GetAllAssetsWithFilter

func (ic *ImmichClient) GetAllAssetsWithFilter(ctx context.Context, query *SearchMetadataQuery, filter func(*Asset) error) error

func (*ImmichClient) GetAllTags

func (ic *ImmichClient) GetAllTags(ctx context.Context) ([]TagSimplified, error)

func (*ImmichClient) GetAssetAlbums

func (ic *ImmichClient) GetAssetAlbums(ctx context.Context, assetID string) ([]AlbumSimplified, error)

func (*ImmichClient) GetAssetInfo

func (ic *ImmichClient) GetAssetInfo(ctx context.Context, id string) (*Asset, error)

func (*ImmichClient) GetAssetStatistics

func (ic *ImmichClient) GetAssetStatistics(ctx context.Context) (UserStatistics, error)

func (*ImmichClient) GetAssetsAlbums

func (ic *ImmichClient) GetAssetsAlbums(ctx context.Context, id string) ([]assets.Album, error)

func (*ImmichClient) GetAssetsByHash

func (ic *ImmichClient) GetAssetsByHash(ctx context.Context, hash string) ([]*Asset, error)

GetAssetByHash returns the asset with the given hash The hash is the base64 encoded sha1 of the file

func (*ImmichClient) GetAssetsByImageName

func (ic *ImmichClient) GetAssetsByImageName(ctx context.Context, name string) ([]*Asset, error)

GetAssetByHash returns the asset with the given hash The hash is the base64 encoded sha1 of the file

func (*ImmichClient) GetEndPoint

func (ic *ImmichClient) GetEndPoint() string

func (*ImmichClient) GetJobs

func (ic *ImmichClient) GetJobs(ctx context.Context) (map[string]Job, error)

func (*ImmichClient) GetServerStatistics

func (ic *ImmichClient) GetServerStatistics(ctx context.Context) (ServerStatistics, error)

func (*ImmichClient) GetSupportedMediaTypes

func (ic *ImmichClient) GetSupportedMediaTypes(ctx context.Context) (filetypes.SupportedMedia, error)

func (*ImmichClient) IsExtensionPrefix

func (ic *ImmichClient) IsExtensionPrefix(ext string) bool

func (*ImmichClient) IsIgnoredExt

func (ic *ImmichClient) IsIgnoredExt(ext string) bool

func (*ImmichClient) PingServer

func (ic *ImmichClient) PingServer(ctx context.Context) error

Ping server

func (*ImmichClient) ReplaceAsset

func (ic *ImmichClient) ReplaceAsset(ctx context.Context, ID string, la *assets.Asset) (AssetResponse, error)

func (*ImmichClient) SendJobCommand

func (ic *ImmichClient) SendJobCommand(
	ctx context.Context,
	jobID JobID,
	command JobCommand,
	force bool,
) (resp SendJobCommandResponse, err error)

func (*ImmichClient) SetDeviceUUID

func (ic *ImmichClient) SetDeviceUUID(deviceUUID string)

func (*ImmichClient) SetEndPoint

func (ic *ImmichClient) SetEndPoint(endPoint string)

func (*ImmichClient) SupportedMedia

func (ic *ImmichClient) SupportedMedia() filetypes.SupportedMedia

func (*ImmichClient) TagAssets

func (ic *ImmichClient) TagAssets(
	ctx context.Context,
	tagID string,
	assetIDs []string,
) ([]TagAssetsResponse, error)

func (*ImmichClient) TypeFromExt

func (ic *ImmichClient) TypeFromExt(ext string) string

func (*ImmichClient) UpdateAsset

func (ic *ImmichClient) UpdateAsset(ctx context.Context, id string, param UpdAssetField) (*Asset, error)

func (*ImmichClient) UpdateAssets

func (ic *ImmichClient) UpdateAssets(ctx context.Context, ids []string,
	isArchived bool, isFavorite bool,
	latitude float64, longitude float64,
	removeParent bool, stackParentID string,
) error

func (*ImmichClient) UpsertTags

func (ic *ImmichClient) UpsertTags(ctx context.Context, tags []string) ([]TagSimplified, error)

func (*ImmichClient) ValidateConnection

func (ic *ImmichClient) ValidateConnection(ctx context.Context) (User, error)

type ImmichClientInterface

type ImmichClientInterface interface {
	SetEndPoint(string)
	EnableAppTrace(w io.Writer)
	SetDeviceUUID(string)
	PingServer(ctx context.Context) error
	ValidateConnection(ctx context.Context) (User, error)
	GetServerStatistics(ctx context.Context) (ServerStatistics, error)
	GetAssetStatistics(ctx context.Context) (UserStatistics, error)
	SupportedMedia() filetypes.SupportedMedia
	GetAboutInfo(ctx context.Context) (AboutInfo, error)
}

type ImmichExifTime

type ImmichExifTime struct {
	time.Time
}

func (ImmichExifTime) MarshalJSON

func (t ImmichExifTime) MarshalJSON() ([]byte, error)

func (*ImmichExifTime) UnmarshalJSON

func (t *ImmichExifTime) UnmarshalJSON(b []byte) error

type ImmichInterface

ImmichInterface is an interface that implements the minimal immich client set of features for uploading interface used to mock up the client

type ImmichJobInterface

type ImmichJobInterface interface {
	GetJobs(ctx context.Context) (map[string]Job, error)
	SendJobCommand(
		ctx context.Context,
		jobID JobID,
		command JobCommand,
		force bool,
	) (SendJobCommandResponse, error)
	CreateJob(ctx context.Context, name JobName) error
}

type ImmichStackInterface

type ImmichStackInterface interface {
	// CreateStack create a stack with the given assets, the 1st asset is the cover, return the stack ID
	CreateStack(ctx context.Context, ids []string) (string, error)
}

type ImmichTagInterface

type ImmichTagInterface interface {
	GetAllTags(ctx context.Context) ([]TagSimplified, error)
	UpsertTags(ctx context.Context, tags []string) ([]TagSimplified, error)
	TagAssets(
		ctx context.Context,
		tagID string,
		assetIDs []string,
	) ([]TagAssetsResponse, error)
	BulkTagAssets(
		ctx context.Context,
		tagIDs []string,
		assetIDs []string,
	) (struct {
		Count int `json:"count"`
	}, error)
}

type ImmichTime

type ImmichTime struct {
	time.Time
}

func (ImmichTime) MarshalJSON

func (t ImmichTime) MarshalJSON() ([]byte, error)

func (*ImmichTime) UnmarshalJSON

func (t *ImmichTime) UnmarshalJSON(b []byte) error

type Job

type Job struct {
	JobCounts struct {
		Active    int `json:"active"`
		Completed int `json:"completed"`
		Failed    int `json:"failed"`
		Delayed   int `json:"delayed"`
		Waiting   int `json:"waiting"`
		Paused    int `json:"paused"`
	} `json:"jobCounts"`
	QueueStatus struct {
		IsActive bool `json:"isActive"`
		IsPaused bool `json:"isPaused"`
	} `json:"queueStatus"`
}

type JobCommand

type JobCommand string
const (
	Start       JobCommand = "start"
	Pause       JobCommand = "pause"
	Resume      JobCommand = "resume"
	Empty       JobCommand = "empty"
	ClearFailed JobCommand = "clear-failed"
)

type JobID

type JobID string
const (
	StorageTemplateMigration JobID = "storageTemplateMigration"
)

type JobName

type JobName string
const (
	PersonCleanup JobName = "person-cleanup"
	TagCleanup    JobName = "tag-cleanup"
	UserCleanup   JobName = "user-cleanup"
)

type PingResponse

type PingResponse struct {
	Res string `json:"res"`
}

type SearchMetadataQuery

type SearchMetadataQuery struct {
	// pagination
	Page int `json:"page"`
	Size int `json:"size,omitempty"`

	// filters
	WithExif         bool   `json:"withExif,omitempty"`
	IsVisible        bool   `json:"isVisible,omitempty"` // For motion stuff you need to pass isVisible=true to hide the motion ones (dijrasm91 — https://discord.com/channels/979116623879368755/1178366369423700080/1201206313699508295)
	WithDeleted      bool   `json:"withDeleted,omitempty"`
	WithArchived     bool   `json:"withArchived,omitempty"`
	TakenBefore      string `json:"takenBefore,omitempty"`
	TakenAfter       string `json:"takenAfter,omitempty"`
	Model            string `json:"model,omitempty"`
	Make             string `json:"make,omitempty"`
	Checksum         string `json:"checksum,omitempty"`
	OriginalFileName string `json:"originalFileName,omitempty"`
}

type SendJobCommandResponse

type SendJobCommandResponse struct {
	JobCounts struct {
		Active    int `json:"active"`
		Completed int `json:"completed"`
		Delayed   int `json:"delayed"`
		Failed    int `json:"failed"`
		Paused    int `json:"paused"`
		Waiting   int `json:"waiting"`
	} `json:"jobCounts"`
	QueueStatus struct {
		IsActive bool `json:"isActive"`
		IsPause  bool `json:"isPause"`
	}
}

type ServerErrorMessage

type ServerErrorMessage struct {
	Error         string `json:"error"`
	StatusCode    int    `json:"statusCode"`
	Message       string `json:"message"`
	CorrelationID string `json:"correlationId"`
}

type ServerStatistics

type ServerStatistics struct {
	Photos      int   `json:"photos"`
	Videos      int   `json:"videos"`
	Usage       int64 `json:"usage"`
	UsageByUser []struct {
		UserID           string `json:"userId"`
		UserName         string `json:"userName"`
		Photos           int    `json:"photos"`
		Videos           int    `json:"videos"`
		Usage            int64  `json:"usage"`
		QuotaSizeInBytes any    `json:"quotaSizeInBytes"`
	} `json:"usageByUser"`
}

type TagAssetsResponse

type TagAssetsResponse struct {
	Error   string `json:"error,omitempty"` // [duplicate, no_permission, not_found, unknown]
	ID      string `json:"id"`
	Success bool   `json:"success"`
}

type TagSimplified

type TagSimplified struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

func (TagSimplified) AsTag

func (ts TagSimplified) AsTag() assets.Tag

type TooManyInternalError

type TooManyInternalError struct {
	// contains filtered or unexported fields
}

func (TooManyInternalError) Is

func (e TooManyInternalError) Is(target error) bool

type UnsupportedMedia

type UnsupportedMedia struct {
	// contains filtered or unexported fields
}

func (UnsupportedMedia) Error

func (u UnsupportedMedia) Error() string

func (UnsupportedMedia) Is

func (u UnsupportedMedia) Is(target error) bool

type UpdAssetField

type UpdAssetField struct {
	IsArchived       bool      `json:"isArchived,omitempty"`
	IsFavorite       bool      `json:"isFavorite,omitempty"`
	Latitude         float64   `json:"latitude,omitempty"`
	Longitude        float64   `json:"longitude,omitempty"`
	Description      string    `json:"description,omitempty"`
	Rating           int       `json:"rating,omitempty"`
	DateTimeOriginal time.Time `json:"dateTimeOriginal,omitempty"`
}

UpdAssetField is used to update asset with fields given in the struct fields

func (UpdAssetField) MarshalJSON added in v0.25.2

func (u UpdAssetField) MarshalJSON() ([]byte, error)

MarshalJSON customizes the JSON marshaling for the UpdAssetField struct. If either Latitude or Longitude is non-zero, it includes them in the JSON output. Otherwise, it omits them by using the alias type.

type UpdateAlbum

type UpdateAlbum struct {
	IDS []string `json:"ids"`
}

type UpdateAlbumResult

type UpdateAlbumResult struct {
	ID      string `json:"id"`
	Success bool   `json:"success"`
	Error   string `json:"error,omitempty"`
}

type User

type User struct {
	ID                   string    `json:"id"`
	Email                string    `json:"email"`
	FirstName            string    `json:"firstName"`
	LastName             string    `json:"lastName"`
	StorageLabel         string    `json:"storageLabel"`
	ExternalPath         string    `json:"externalPath"`
	ProfileImagePath     string    `json:"profileImagePath"`
	ShouldChangePassword bool      `json:"shouldChangePassword"`
	IsAdmin              bool      `json:"isAdmin"`
	CreatedAt            time.Time `json:"createdAt"`
	DeletedAt            time.Time `json:"deletedAt"`
	UpdatedAt            time.Time `json:"updatedAt"`
	OauthID              string    `json:"oauthId"`
}

type UserStatistics

type UserStatistics struct {
	Images int `json:"images"`
	Videos int `json:"videos"`
	Total  int `json:"total"`
}

Jump to

Keyboard shortcuts

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