syncawesome

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

README

Syncawesome Go API Library

Go Reference

The Syncawesome Go library provides convenient access to the Syncawesome REST API from applications written in Go.

It is generated with Stainless.

MCP Server

Use the Syncawesome MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.

Add to Cursor Install in VS Code

Note: You may need to set environment variables in your MCP client.

Installation

import (
	"github.com/shaneosullivan/syncawesomeclient-go" // imported as syncawesome
)

Or to pin the version:

go get -u 'github.com/shaneosullivan/syncawesomeclient-go@v0.1.0'

Requirements

This library requires Go 1.22+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/shaneosullivan/syncawesomeclient-go"
	"github.com/shaneosullivan/syncawesomeclient-go/option"
)

func main() {
	client := syncawesome.NewClient(
		option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("SYNCAWESOME_API_KEY")
	)
	response, err := client.Health.Check(context.TODO())
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.DeviceID)
}

Request fields

The syncawesome library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `api:"required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, syncawesome.String(string), syncawesome.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := syncawesome.ExampleParams{
	ID:   "id_xxx",                  // required property
	Name: syncawesome.String("..."), // optional property

	Point: syncawesome.Point{
		X: 0,                  // required field will serialize as 0
		Y: syncawesome.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: syncawesome.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[syncawesome.FooParams](12)
Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := syncawesome.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Health.Check(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

iter := client.Media.ListAutoPaging(context.TODO(), syncawesome.MediaListParams{})
// Automatically fetches more pages as needed.
for iter.Next() {
	mediaListResponse := iter.Current()
	fmt.Printf("%+v\n", mediaListResponse)
}
if err := iter.Err(); err != nil {
	panic(err.Error())
}

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

page, err := client.Media.List(context.TODO(), syncawesome.MediaListParams{})
for page != nil {
	for _, media := range page.Data {
		fmt.Printf("%+v\n", media)
	}
	page, err = page.GetNextPage()
}
if err != nil {
	panic(err.Error())
}
Errors

When the API returns a non-success status code, we return an error with type *syncawesome.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Health.Check(context.TODO())
if err != nil {
	var apierr *syncawesome.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/health": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Health.Check(
	ctx,
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper syncawesome.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := syncawesome.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Health.Check(context.TODO(), option.WithMaxRetries(5))
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
response, err := client.Health.Check(context.TODO(), option.WithResponseInto(&response))
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", response)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: syncawesome.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := syncawesome.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (SYNCAWESOME_API_KEY, SYNCAWESOME_CLIENT_IP, SYNCAWESOME_PORT, SYNCAWESOME_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type AlbumListResponse

type AlbumListResponse struct {
	// Number of items returned in this page
	Count int64 `json:"count" api:"required"`
	// Array of albums
	Data []AlbumListResponseData `json:"data" api:"required"`
	// Object type indicator for list responses
	//
	// Any of "list".
	Object AlbumListResponseObject `json:"object" api:"required"`
	// Starting index of this page
	Offset int64 `json:"offset" api:"required"`
	// Total number of albums
	TotalCount int64 `json:"total_count" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Count       respjson.Field
		Data        respjson.Field
		Object      respjson.Field
		Offset      respjson.Field
		TotalCount  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AlbumListResponse) RawJSON

func (r AlbumListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AlbumListResponse) UnmarshalJSON

func (r *AlbumListResponse) UnmarshalJSON(data []byte) error

type AlbumListResponseData

type AlbumListResponseData struct {
	// Unique album identifier
	ID string `json:"id" api:"required"`
	// ID of cover media item
	CoverMediaID string `json:"cover_media_id" api:"required"`
	// Album creation timestamp (Unix seconds)
	CreatedAt int64 `json:"created_at" api:"required"`
	// Number of items in album
	ItemCount int64 `json:"item_count" api:"required"`
	// Object type indicator
	//
	// Any of "album".
	Object string `json:"object" api:"required"`
	// Album title
	Title string `json:"title" api:"required"`
	// Album type (smart = system, user = created by user)
	//
	// Any of "smart", "user".
	Type string `json:"type" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		CoverMediaID respjson.Field
		CreatedAt    respjson.Field
		ItemCount    respjson.Field
		Object       respjson.Field
		Title        respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AlbumListResponseData) RawJSON

func (r AlbumListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*AlbumListResponseData) UnmarshalJSON

func (r *AlbumListResponseData) UnmarshalJSON(data []byte) error

type AlbumListResponseObject

type AlbumListResponseObject string

Object type indicator for list responses

const (
	AlbumListResponseObjectList AlbumListResponseObject = "list"
)

type AlbumService

type AlbumService struct {
	Options []option.RequestOption
}

Photo albums

AlbumService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAlbumService method instead.

func NewAlbumService

func NewAlbumService(opts ...option.RequestOption) (r AlbumService)

NewAlbumService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AlbumService) List

func (r *AlbumService) List(ctx context.Context, opts ...option.RequestOption) (res *AlbumListResponse, err error)

List all photo albums (both smart albums and user-created albums).

type ChangeListParams

type ChangeListParams struct {
	// Starting index (0-based) for pagination
	Offset param.Opt[int64] `query:"offset,omitzero" json:"-"`
	// Number of changes to return (1-500)
	Count param.Opt[int64] `query:"count,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ChangeListParams) URLQuery

func (r ChangeListParams) URLQuery() (v url.Values, err error)

URLQuery serializes ChangeListParams's query parameters as `url.Values`.

type ChangeListResponse

type ChangeListResponse struct {
	// Unique change identifier
	ID    string                  `json:"id" api:"required"`
	Media ChangeListResponseMedia `json:"media" api:"required"`
	// ID of affected media
	MediaID string `json:"media_id" api:"required"`
	// Object type indicator
	//
	// Any of "change".
	Object ChangeListResponseObject `json:"object" api:"required"`
	// When the change occurred (Unix seconds)
	Timestamp int64 `json:"timestamp" api:"required"`
	// Type of change
	//
	// Any of "added", "modified", "deleted".
	Type ChangeListResponseType `json:"type" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Media       respjson.Field
		MediaID     respjson.Field
		Object      respjson.Field
		Timestamp   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChangeListResponse) RawJSON

func (r ChangeListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChangeListResponse) UnmarshalJSON

func (r *ChangeListResponse) UnmarshalJSON(data []byte) error

type ChangeListResponseMedia

type ChangeListResponseMedia struct {
	// Unique media identifier (PHAsset localIdentifier)
	ID string `json:"id" api:"required"`
	// Creation timestamp (Unix seconds)
	CreatedAt int64 `json:"created_at" api:"required"`
	// Original filename
	Filename string `json:"filename" api:"required"`
	// Whether the media is a Live Photo (image with paired video)
	IsLivePhoto bool `json:"is_live_photo" api:"required"`
	// Whether the media is a screenshot (detected via iOS PHAssetMediaSubtype)
	IsScreenshot bool `json:"is_screenshot" api:"required"`
	// GPS coordinates if available
	Location ChangeListResponseMediaLocation `json:"location" api:"required"`
	// MIME type (e.g., image/jpeg, video/mp4)
	MimeType string `json:"mime_type" api:"required"`
	// Modification timestamp (Unix seconds)
	ModifiedAt int64 `json:"modified_at" api:"required"`
	// Object type indicator
	//
	// Any of "media".
	Object string `json:"object" api:"required"`
	// Duration in seconds (videos only)
	Duration float64 `json:"duration"`
	// Height in pixels
	Height int64 `json:"height"`
	// Width in pixels
	Width int64 `json:"width"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		CreatedAt    respjson.Field
		Filename     respjson.Field
		IsLivePhoto  respjson.Field
		IsScreenshot respjson.Field
		Location     respjson.Field
		MimeType     respjson.Field
		ModifiedAt   respjson.Field
		Object       respjson.Field
		Duration     respjson.Field
		Height       respjson.Field
		Width        respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChangeListResponseMedia) RawJSON

func (r ChangeListResponseMedia) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChangeListResponseMedia) UnmarshalJSON

func (r *ChangeListResponseMedia) UnmarshalJSON(data []byte) error

type ChangeListResponseMediaLocation

type ChangeListResponseMediaLocation struct {
	// Latitude
	Lat float64 `json:"lat" api:"required"`
	// Longitude
	Lng float64 `json:"lng" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Lat         respjson.Field
		Lng         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

GPS coordinates if available

func (ChangeListResponseMediaLocation) RawJSON

Returns the unmodified JSON received from the API

func (*ChangeListResponseMediaLocation) UnmarshalJSON

func (r *ChangeListResponseMediaLocation) UnmarshalJSON(data []byte) error

type ChangeListResponseObject

type ChangeListResponseObject string

Object type indicator

const (
	ChangeListResponseObjectChange ChangeListResponseObject = "change"
)

type ChangeListResponseType

type ChangeListResponseType string

Type of change

const (
	ChangeListResponseTypeAdded    ChangeListResponseType = "added"
	ChangeListResponseTypeModified ChangeListResponseType = "modified"
	ChangeListResponseTypeDeleted  ChangeListResponseType = "deleted"
)

type ChangeService

type ChangeService struct {
	Options []option.RequestOption
}

Change tracking for sync

ChangeService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewChangeService method instead.

func NewChangeService

func NewChangeService(opts ...option.RequestOption) (r ChangeService)

NewChangeService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ChangeService) List

Get recently modified media items. Useful for incremental sync.

**Pagination**: Uses cursor-based pagination:

- Pass `next_cursor` from the response as `cursor` to get the next page - `has_more` indicates if more changes exist

func (*ChangeService) ListAutoPaging

Get recently modified media items. Useful for incremental sync.

**Pagination**: Uses cursor-based pagination:

- Pass `next_cursor` from the response as `cursor` to get the next page - `has_more` indicates if more changes exist

type Client

type Client struct {
	Options []option.RequestOption
	// Server health and status
	Health HealthService
	// Session authentication
	Handshake HandshakeService
	// Media listing and download
	Media MediaService
	// Photo albums
	Albums AlbumService
	// Change tracking for sync
	Changes ChangeService
	// Virtual filesystem for FUSE mounting
	Fs FService
	// Change tracking for sync
	Sync SyncService
	// People/face thumbnails
	People PersonService
	// Connection management
	Connect ConnectService
	// Connection management
	Usb UsbService
}

Client creates a struct with services and top level methods that help with interacting with the syncawesome API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (SYNCAWESOME_API_KEY, SYNCAWESOME_CLIENT_IP, SYNCAWESOME_PORT, SYNCAWESOME_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type ConnectService

type ConnectService struct {
	Options []option.RequestOption
}

Connection management

ConnectService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewConnectService method instead.

func NewConnectService

func NewConnectService(opts ...option.RequestOption) (r ConnectService)

NewConnectService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ConnectService) Try

Request the client to attempt connecting to a server.

This endpoint is called by the server when it starts up and wants to trigger immediate connection attempts from clients it has previously seen.

The client will check if it's already connected to the specified server. If not, it will initiate a connection attempt.

type ConnectTryParams

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

func (ConnectTryParams) MarshalJSON

func (r ConnectTryParams) MarshalJSON() (data []byte, err error)

func (*ConnectTryParams) UnmarshalJSON

func (r *ConnectTryParams) UnmarshalJSON(data []byte) error

type ConnectTryResponse

type ConnectTryResponse struct {
	// Object type indicator
	//
	// Any of "connect_attempt".
	Object ConnectTryResponseObject `json:"object" api:"required"`
	// Status of the connection attempt
	//
	// Any of "connecting", "already_connected", "failed".
	Status ConnectTryResponseStatus `json:"status" api:"required"`
	// Additional status message
	Message string `json:"message"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Object      respjson.Field
		Status      respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ConnectTryResponse) RawJSON

func (r ConnectTryResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ConnectTryResponse) UnmarshalJSON

func (r *ConnectTryResponse) UnmarshalJSON(data []byte) error

type ConnectTryResponseObject

type ConnectTryResponseObject string

Object type indicator

const (
	ConnectTryResponseObjectConnectAttempt ConnectTryResponseObject = "connect_attempt"
)

type ConnectTryResponseStatus

type ConnectTryResponseStatus string

Status of the connection attempt

const (
	ConnectTryResponseStatusConnecting       ConnectTryResponseStatus = "connecting"
	ConnectTryResponseStatusAlreadyConnected ConnectTryResponseStatus = "already_connected"
	ConnectTryResponseStatusFailed           ConnectTryResponseStatus = "failed"
)

type Error

type Error = apierror.Error

type FListParams

type FListParams struct {
	// Starting index (0-based) for pagination
	Offset param.Opt[int64] `query:"offset,omitzero" json:"-"`
	// Number of entries to return (1-500)
	Count param.Opt[int64] `query:"count,omitzero" json:"-"`
	// Virtual path to list
	Path param.Opt[string] `query:"path,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (FListParams) URLQuery

func (r FListParams) URLQuery() (v url.Values, err error)

URLQuery serializes FListParams's query parameters as `url.Values`.

type FListResponse

type FListResponse struct {
	// Creation timestamp (Unix seconds)
	CreatedAt int64 `json:"created_at" api:"required"`
	// Media ID for file entries
	MediaID string `json:"media_id" api:"required"`
	// MIME type for files
	MimeType string `json:"mime_type" api:"required"`
	// Modification timestamp (Unix seconds)
	ModifiedAt int64 `json:"modified_at" api:"required"`
	// Entry name
	Name string `json:"name" api:"required"`
	// Object type indicator
	//
	// Any of "fs_entry".
	Object FListResponseObject `json:"object" api:"required"`
	// File size in bytes
	Size int64 `json:"size" api:"required"`
	// Entry type
	//
	// Any of "file", "directory".
	Type FListResponseType `json:"type" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CreatedAt   respjson.Field
		MediaID     respjson.Field
		MimeType    respjson.Field
		ModifiedAt  respjson.Field
		Name        respjson.Field
		Object      respjson.Field
		Size        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FListResponse) RawJSON

func (r FListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*FListResponse) UnmarshalJSON

func (r *FListResponse) UnmarshalJSON(data []byte) error

type FListResponseObject

type FListResponseObject string

Object type indicator

const (
	FListResponseObjectFsEntry FListResponseObject = "fs_entry"
)

type FListResponseType

type FListResponseType string

Entry type

const (
	FListResponseTypeFile      FListResponseType = "file"
	FListResponseTypeDirectory FListResponseType = "directory"
)

type FReadParams

type FReadParams struct {
	// Virtual path to read
	Path string `query:"path" api:"required" json:"-"`
	// Byte offset to start reading
	Offset param.Opt[int64] `query:"offset,omitzero" json:"-"`
	// Number of bytes to read
	Length param.Opt[int64] `query:"length,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (FReadParams) URLQuery

func (r FReadParams) URLQuery() (v url.Values, err error)

URLQuery serializes FReadParams's query parameters as `url.Values`.

type FService

type FService struct {
	Options []option.RequestOption
}

Virtual filesystem for FUSE mounting

FService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFService method instead.

func NewFService

func NewFService(opts ...option.RequestOption) (r FService)

NewFService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*FService) List

func (r *FService) List(ctx context.Context, query FListParams, opts ...option.RequestOption) (res *pagination.OffsetPage[FListResponse], err error)

List entries in a virtual directory.

**Virtual filesystem structure**:

``` / ├── All Photos/ ├── All Videos/ ├── By Date/{year}/{month}/{day}/ ├── Albums/{album_name}/ └── By Type/Photos|Videos/ ```

func (*FService) ListAutoPaging

List entries in a virtual directory.

**Virtual filesystem structure**:

``` / ├── All Photos/ ├── All Videos/ ├── By Date/{year}/{month}/{day}/ ├── Albums/{album_name}/ └── By Type/Photos|Videos/ ```

func (*FService) Read

func (r *FService) Read(ctx context.Context, query FReadParams, opts ...option.RequestOption) (err error)

Read a byte range from a virtual file. Useful for FUSE read operations.

func (*FService) Stat

func (r *FService) Stat(ctx context.Context, query FStatParams, opts ...option.RequestOption) (res *FStatResponse, err error)

Get metadata about a virtual file or directory. Useful for FUSE getattr operations.

type FStatParams

type FStatParams struct {
	// Virtual path to stat
	Path string `query:"path" api:"required" json:"-"`
	// contains filtered or unexported fields
}

func (FStatParams) URLQuery

func (r FStatParams) URLQuery() (v url.Values, err error)

URLQuery serializes FStatParams's query parameters as `url.Values`.

type FStatResponse

type FStatResponse struct {
	// Creation timestamp (Unix seconds)
	CreatedAt int64 `json:"created_at" api:"required"`
	// Whether the path exists
	Exists bool `json:"exists" api:"required"`
	// Media ID for file entries
	MediaID string `json:"media_id" api:"required"`
	// MIME type for files
	MimeType string `json:"mime_type" api:"required"`
	// Modification timestamp (Unix seconds)
	ModifiedAt int64 `json:"modified_at" api:"required"`
	// Object type indicator
	//
	// Any of "fs_stat".
	Object FStatResponseObject `json:"object" api:"required"`
	// The path that was stat'd
	Path string `json:"path" api:"required"`
	// Unix-style permission string
	Permissions string `json:"permissions" api:"required"`
	// File size in bytes
	Size int64 `json:"size" api:"required"`
	// Entry type if exists
	//
	// Any of "file", "directory".
	Type FStatResponseType `json:"type" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CreatedAt   respjson.Field
		Exists      respjson.Field
		MediaID     respjson.Field
		MimeType    respjson.Field
		ModifiedAt  respjson.Field
		Object      respjson.Field
		Path        respjson.Field
		Permissions respjson.Field
		Size        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FStatResponse) RawJSON

func (r FStatResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*FStatResponse) UnmarshalJSON

func (r *FStatResponse) UnmarshalJSON(data []byte) error

type FStatResponseObject

type FStatResponseObject string

Object type indicator

const (
	FStatResponseObjectFsStat FStatResponseObject = "fs_stat"
)

type FStatResponseType

type FStatResponseType string

Entry type if exists

const (
	FStatResponseTypeFile      FStatResponseType = "file"
	FStatResponseTypeDirectory FStatResponseType = "directory"
)

type HandshakeCompleteParams

type HandshakeCompleteParams struct {
	// Challenge token from website API
	Challenge string `json:"challenge" api:"required"`
	// Requesting device ID
	DeviceID string `json:"device_id" api:"required"`
	// Requesting device name
	DeviceName string `json:"device_name" api:"required"`
	// contains filtered or unexported fields
}

func (HandshakeCompleteParams) MarshalJSON

func (r HandshakeCompleteParams) MarshalJSON() (data []byte, err error)

func (*HandshakeCompleteParams) UnmarshalJSON

func (r *HandshakeCompleteParams) UnmarshalJSON(data []byte) error

type HandshakeCompleteResponse

type HandshakeCompleteResponse struct {
	// Whether this device was previously known
	DeviceKnown bool `json:"device_known" api:"required"`
	// Object type indicator
	//
	// Any of "session".
	Object HandshakeCompleteResponseObject `json:"object" api:"required"`
	// Server protocol version
	ProtocolVersion int64 `json:"protocol_version" api:"required"`
	// Session key for subsequent requests
	SessionKey string `json:"session_key" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		DeviceKnown     respjson.Field
		Object          respjson.Field
		ProtocolVersion respjson.Field
		SessionKey      respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (HandshakeCompleteResponse) RawJSON

func (r HandshakeCompleteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*HandshakeCompleteResponse) UnmarshalJSON

func (r *HandshakeCompleteResponse) UnmarshalJSON(data []byte) error

type HandshakeCompleteResponseObject

type HandshakeCompleteResponseObject string

Object type indicator

const (
	HandshakeCompleteResponseObjectSession HandshakeCompleteResponseObject = "session"
)

type HandshakeService

type HandshakeService struct {
	Options []option.RequestOption
}

Session authentication

HandshakeService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewHandshakeService method instead.

func NewHandshakeService

func NewHandshakeService(opts ...option.RequestOption) (r HandshakeService)

NewHandshakeService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*HandshakeService) Complete

Complete the authentication handshake to obtain a session key.

type HealthCheckResponse

type HealthCheckResponse struct {
	// Unique device identifier
	DeviceID string `json:"device_id" api:"required"`
	// Human-readable device name
	DeviceName string `json:"device_name" api:"required"`
	// Any of "client".
	DeviceType HealthCheckResponseDeviceType `json:"device_type" api:"required"`
	MediaCount HealthCheckResponseMediaCount `json:"media_count" api:"required"`
	// Object type indicator
	//
	// Any of "health".
	Object HealthCheckResponseObject `json:"object" api:"required"`
	// Client protocol version
	ProtocolVersion int64 `json:"protocol_version" api:"required"`
	// Any of "ok".
	Status HealthCheckResponseStatus `json:"status" api:"required"`
	// Unix timestamp in seconds
	Timestamp int64 `json:"timestamp" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		DeviceID        respjson.Field
		DeviceName      respjson.Field
		DeviceType      respjson.Field
		MediaCount      respjson.Field
		Object          respjson.Field
		ProtocolVersion respjson.Field
		Status          respjson.Field
		Timestamp       respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (HealthCheckResponse) RawJSON

func (r HealthCheckResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*HealthCheckResponse) UnmarshalJSON

func (r *HealthCheckResponse) UnmarshalJSON(data []byte) error

type HealthCheckResponseDeviceType

type HealthCheckResponseDeviceType string
const (
	HealthCheckResponseDeviceTypeClient HealthCheckResponseDeviceType = "client"
)

type HealthCheckResponseMediaCount

type HealthCheckResponseMediaCount struct {
	Photos int64 `json:"photos" api:"required"`
	Videos int64 `json:"videos" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Photos      respjson.Field
		Videos      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (HealthCheckResponseMediaCount) RawJSON

Returns the unmodified JSON received from the API

func (*HealthCheckResponseMediaCount) UnmarshalJSON

func (r *HealthCheckResponseMediaCount) UnmarshalJSON(data []byte) error

type HealthCheckResponseObject

type HealthCheckResponseObject string

Object type indicator

const (
	HealthCheckResponseObjectHealth HealthCheckResponseObject = "health"
)

type HealthCheckResponseStatus

type HealthCheckResponseStatus string
const (
	HealthCheckResponseStatusOk HealthCheckResponseStatus = "ok"
)

type HealthService

type HealthService struct {
	Options []option.RequestOption
}

Server health and status

HealthService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewHealthService method instead.

func NewHealthService

func NewHealthService(opts ...option.RequestOption) (r HealthService)

NewHealthService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*HealthService) Check

func (r *HealthService) Check(ctx context.Context, opts ...option.RequestOption) (res *HealthCheckResponse, err error)

Returns device info and media counts. Does not require authentication.

type MediaDownloadContentParams

type MediaDownloadContentParams struct {
	// HTTP Range header (e.g., bytes=0-1023)
	Range param.Opt[string] `header:"Range,omitzero" json:"-"`
	// Output format (jpeg converts HEIC to JPEG)
	//
	// Any of "original", "jpeg".
	Format MediaDownloadContentParamsFormat `query:"format,omitzero" json:"-"`
	// Requested size: thumbnail (200x200), medium (1024x1024), or full
	//
	// Any of "thumbnail", "medium", "full".
	Size MediaDownloadContentParamsSize `query:"size,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (MediaDownloadContentParams) URLQuery

func (r MediaDownloadContentParams) URLQuery() (v url.Values, err error)

URLQuery serializes MediaDownloadContentParams's query parameters as `url.Values`.

type MediaDownloadContentParamsFormat

type MediaDownloadContentParamsFormat string

Output format (jpeg converts HEIC to JPEG)

const (
	MediaDownloadContentParamsFormatOriginal MediaDownloadContentParamsFormat = "original"
	MediaDownloadContentParamsFormatJpeg     MediaDownloadContentParamsFormat = "jpeg"
)

type MediaDownloadContentParamsSize

type MediaDownloadContentParamsSize string

Requested size: thumbnail (200x200), medium (1024x1024), or full

const (
	MediaDownloadContentParamsSizeThumbnail MediaDownloadContentParamsSize = "thumbnail"
	MediaDownloadContentParamsSizeMedium    MediaDownloadContentParamsSize = "medium"
	MediaDownloadContentParamsSizeFull      MediaDownloadContentParamsSize = "full"
)

type MediaGetResponse

type MediaGetResponse struct {
	// Unique media identifier (PHAsset localIdentifier)
	ID string `json:"id" api:"required"`
	// IDs of albums containing this media
	AlbumIDs []string `json:"album_ids" api:"required"`
	// Creation timestamp (Unix seconds)
	CreatedAt int64 `json:"created_at" api:"required"`
	// Original filename
	Filename string `json:"filename" api:"required"`
	// Whether the media is marked as favorite
	IsFavorite bool `json:"is_favorite" api:"required"`
	// Whether the media is a Live Photo (image with paired video)
	IsLivePhoto bool `json:"is_live_photo" api:"required"`
	// Whether the media is a screenshot (detected via iOS PHAssetMediaSubtype)
	IsScreenshot bool `json:"is_screenshot" api:"required"`
	// Local URI for the media (ph://...)
	LocalUri string `json:"local_uri" api:"required"`
	// GPS coordinates if available
	Location MediaGetResponseLocation `json:"location" api:"required"`
	// MIME type (e.g., image/jpeg, video/mp4)
	MimeType string `json:"mime_type" api:"required"`
	// Modification timestamp (Unix seconds)
	ModifiedAt int64 `json:"modified_at" api:"required"`
	// Object type indicator
	//
	// Any of "media".
	Object MediaGetResponseObject `json:"object" api:"required"`
	// Duration in seconds (videos only)
	Duration float64 `json:"duration"`
	// Height in pixels
	Height int64 `json:"height"`
	// Width in pixels
	Width int64 `json:"width"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		AlbumIDs     respjson.Field
		CreatedAt    respjson.Field
		Filename     respjson.Field
		IsFavorite   respjson.Field
		IsLivePhoto  respjson.Field
		IsScreenshot respjson.Field
		LocalUri     respjson.Field
		Location     respjson.Field
		MimeType     respjson.Field
		ModifiedAt   respjson.Field
		Object       respjson.Field
		Duration     respjson.Field
		Height       respjson.Field
		Width        respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MediaGetResponse) RawJSON

func (r MediaGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*MediaGetResponse) UnmarshalJSON

func (r *MediaGetResponse) UnmarshalJSON(data []byte) error

type MediaGetResponseLocation

type MediaGetResponseLocation struct {
	// Latitude
	Lat float64 `json:"lat" api:"required"`
	// Longitude
	Lng float64 `json:"lng" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Lat         respjson.Field
		Lng         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

GPS coordinates if available

func (MediaGetResponseLocation) RawJSON

func (r MediaGetResponseLocation) RawJSON() string

Returns the unmodified JSON received from the API

func (*MediaGetResponseLocation) UnmarshalJSON

func (r *MediaGetResponseLocation) UnmarshalJSON(data []byte) error

type MediaGetResponseObject

type MediaGetResponseObject string

Object type indicator

const (
	MediaGetResponseObjectMedia MediaGetResponseObject = "media"
)

type MediaListMonthsResponse

type MediaListMonthsResponse struct {
	// Array of months (1-12) that have media in the specified year, sorted ascending
	Data []int64 `json:"data" api:"required"`
	// Object type indicator
	//
	// Any of "months_list".
	Object MediaListMonthsResponseObject `json:"object" api:"required"`
	// The requested year
	Year int64 `json:"year" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Object      respjson.Field
		Year        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MediaListMonthsResponse) RawJSON

func (r MediaListMonthsResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*MediaListMonthsResponse) UnmarshalJSON

func (r *MediaListMonthsResponse) UnmarshalJSON(data []byte) error

type MediaListMonthsResponseObject

type MediaListMonthsResponseObject string

Object type indicator

const (
	MediaListMonthsResponseObjectMonthsList MediaListMonthsResponseObject = "months_list"
)

type MediaListParams

type MediaListParams struct {
	// Starting index (0-based) for pagination
	Offset param.Opt[int64] `query:"offset,omitzero" json:"-"`
	// Filter by album ID (only return media in this album)
	AlbumID param.Opt[string] `query:"album_id,omitzero" json:"-"`
	// Number of items to return (1-500)
	Count param.Opt[int64] `query:"count,omitzero" json:"-"`
	// Only items created after this ISO8601 timestamp
	CreatedAfter param.Opt[time.Time] `query:"created_after,omitzero" format:"date-time" json:"-"`
	// Only items created before this ISO8601 timestamp
	CreatedBefore param.Opt[time.Time] `query:"created_before,omitzero" format:"date-time" json:"-"`
	// Filter by month (1-12). Requires year to be set.
	Month param.Opt[int64] `query:"month,omitzero" json:"-"`
	// Filter by year (e.g., 2024)
	Year param.Opt[int64] `query:"year,omitzero" json:"-"`
	// Sort direction
	//
	// Any of "asc", "desc".
	Order MediaListParamsOrder `query:"order,omitzero" json:"-"`
	// Field to sort by
	//
	// Any of "created_at", "modified_at".
	OrderBy MediaListParamsOrderBy `query:"order_by,omitzero" json:"-"`
	// Filter by media type
	//
	// Any of "photo", "video", "all".
	Type MediaListParamsType `query:"type,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (MediaListParams) URLQuery

func (r MediaListParams) URLQuery() (v url.Values, err error)

URLQuery serializes MediaListParams's query parameters as `url.Values`.

type MediaListParamsOrder

type MediaListParamsOrder string

Sort direction

const (
	MediaListParamsOrderAsc  MediaListParamsOrder = "asc"
	MediaListParamsOrderDesc MediaListParamsOrder = "desc"
)

type MediaListParamsOrderBy

type MediaListParamsOrderBy string

Field to sort by

const (
	MediaListParamsOrderByCreatedAt  MediaListParamsOrderBy = "created_at"
	MediaListParamsOrderByModifiedAt MediaListParamsOrderBy = "modified_at"
)

type MediaListParamsType

type MediaListParamsType string

Filter by media type

const (
	MediaListParamsTypePhoto MediaListParamsType = "photo"
	MediaListParamsTypeVideo MediaListParamsType = "video"
	MediaListParamsTypeAll   MediaListParamsType = "all"
)

type MediaListResponse

type MediaListResponse struct {
	// Unique media identifier (PHAsset localIdentifier)
	ID string `json:"id" api:"required"`
	// Creation timestamp (Unix seconds)
	CreatedAt int64 `json:"created_at" api:"required"`
	// Original filename
	Filename string `json:"filename" api:"required"`
	// Whether the media is a Live Photo (image with paired video)
	IsLivePhoto bool `json:"is_live_photo" api:"required"`
	// Whether the media is a screenshot (detected via iOS PHAssetMediaSubtype)
	IsScreenshot bool `json:"is_screenshot" api:"required"`
	// GPS coordinates if available
	Location MediaListResponseLocation `json:"location" api:"required"`
	// MIME type (e.g., image/jpeg, video/mp4)
	MimeType string `json:"mime_type" api:"required"`
	// Modification timestamp (Unix seconds)
	ModifiedAt int64 `json:"modified_at" api:"required"`
	// Object type indicator
	//
	// Any of "media".
	Object MediaListResponseObject `json:"object" api:"required"`
	// Duration in seconds (videos only)
	Duration float64 `json:"duration"`
	// Height in pixels
	Height int64 `json:"height"`
	// Width in pixels
	Width int64 `json:"width"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		CreatedAt    respjson.Field
		Filename     respjson.Field
		IsLivePhoto  respjson.Field
		IsScreenshot respjson.Field
		Location     respjson.Field
		MimeType     respjson.Field
		ModifiedAt   respjson.Field
		Object       respjson.Field
		Duration     respjson.Field
		Height       respjson.Field
		Width        respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MediaListResponse) RawJSON

func (r MediaListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*MediaListResponse) UnmarshalJSON

func (r *MediaListResponse) UnmarshalJSON(data []byte) error

type MediaListResponseLocation

type MediaListResponseLocation struct {
	// Latitude
	Lat float64 `json:"lat" api:"required"`
	// Longitude
	Lng float64 `json:"lng" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Lat         respjson.Field
		Lng         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

GPS coordinates if available

func (MediaListResponseLocation) RawJSON

func (r MediaListResponseLocation) RawJSON() string

Returns the unmodified JSON received from the API

func (*MediaListResponseLocation) UnmarshalJSON

func (r *MediaListResponseLocation) UnmarshalJSON(data []byte) error

type MediaListResponseObject

type MediaListResponseObject string

Object type indicator

const (
	MediaListResponseObjectMedia MediaListResponseObject = "media"
)

type MediaListYearsResponse

type MediaListYearsResponse struct {
	// Array of years that have media, sorted descending
	Data []int64 `json:"data" api:"required"`
	// Object type indicator
	//
	// Any of "years_list".
	Object MediaListYearsResponseObject `json:"object" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MediaListYearsResponse) RawJSON

func (r MediaListYearsResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*MediaListYearsResponse) UnmarshalJSON

func (r *MediaListYearsResponse) UnmarshalJSON(data []byte) error

type MediaListYearsResponseObject

type MediaListYearsResponseObject string

Object type indicator

const (
	MediaListYearsResponseObjectYearsList MediaListYearsResponseObject = "years_list"
)

type MediaService

type MediaService struct {
	Options []option.RequestOption
}

Media listing and download

MediaService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewMediaService method instead.

func NewMediaService

func NewMediaService(opts ...option.RequestOption) (r MediaService)

NewMediaService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*MediaService) DownloadContent

func (r *MediaService) DownloadContent(ctx context.Context, id string, params MediaDownloadContentParams, opts ...option.RequestOption) (res *http.Response, err error)

Download the actual media file.

**Size options**:

- `thumbnail`: 200x200, cropped square - `medium`: 1024x1024 max, maintains aspect ratio - `full`: Original resolution

**Format conversion**: Use `format=jpeg` to convert HEIC to JPEG.

**Range requests**: Supports HTTP Range header for partial content (206 responses).

func (*MediaService) Fetch

func (r *MediaService) Fetch(ctx context.Context, id string, opts ...option.RequestOption) (res *http.Response, err error)

Fetch raw binary data for a specific media item.

This endpoint is called by the server over USB to pull media files from the client device. Returns the actual file bytes (JPEG, HEVC, MP4, etc.) as application/octet-stream.

The server uses this endpoint when the client calls POST /media/pull on the server, enabling high-speed USB transfers without the client needing to push data to a localhost URL it cannot reach.

func (*MediaService) Get

func (r *MediaService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *MediaGetResponse, err error)

Get detailed metadata for a single media item.

func (*MediaService) List

List media items with cursor-based pagination.

**Pagination**: Uses cursor_id style pagination:

  • Use `starting_after` with the `last_id` from the previous response to get the next page
  • Use `ending_before` with the `first_id` to get the previous page
  • The `has_more` field indicates if more items exist

func (*MediaService) ListAutoPaging

List media items with cursor-based pagination.

**Pagination**: Uses cursor_id style pagination:

  • Use `starting_after` with the `last_id` from the previous response to get the next page
  • Use `ending_before` with the `first_id` to get the previous page
  • The `has_more` field indicates if more items exist

func (*MediaService) ListMonths

func (r *MediaService) ListMonths(ctx context.Context, year int64, opts ...option.RequestOption) (res *MediaListMonthsResponse, err error)

Returns a list of months (1-12) that have media items in the specified year, sorted in ascending order.

func (*MediaService) ListYears

func (r *MediaService) ListYears(ctx context.Context, opts ...option.RequestOption) (res *MediaListYearsResponse, err error)

Returns a list of years that have media items, sorted in descending order (most recent first).

type PersonService

type PersonService struct {
	Options []option.RequestOption
}

People/face thumbnails

PersonService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewPersonService method instead.

func NewPersonService

func NewPersonService(opts ...option.RequestOption) (r PersonService)

NewPersonService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*PersonService) GetThumbnail

func (r *PersonService) GetThumbnail(ctx context.Context, id string, opts ...option.RequestOption) (res *http.Response, err error)

Get the thumbnail image for a person.

Returns binary JPEG image data suitable for use as an `<Image>` source URI. Returns 404 if the person does not exist or has no thumbnail.

type SyncRequestParams

type SyncRequestParams struct {
	// ID of the media item to sync
	MediaID string `json:"media_id" api:"required"`
	// contains filtered or unexported fields
}

func (SyncRequestParams) MarshalJSON

func (r SyncRequestParams) MarshalJSON() (data []byte, err error)

func (*SyncRequestParams) UnmarshalJSON

func (r *SyncRequestParams) UnmarshalJSON(data []byte) error

type SyncRequestResponse

type SyncRequestResponse struct {
	// ID of the media item being synced
	MediaID string `json:"media_id" api:"required"`
	// Object type indicator
	//
	// Any of "sync_request".
	Object SyncRequestResponseObject `json:"object" api:"required"`
	// Current status of the sync request
	//
	// Any of "queued", "in_progress", "completed", "failed".
	Status SyncRequestResponseStatus `json:"status" api:"required"`
	// Additional status message
	Message string `json:"message"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		MediaID     respjson.Field
		Object      respjson.Field
		Status      respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SyncRequestResponse) RawJSON

func (r SyncRequestResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SyncRequestResponse) UnmarshalJSON

func (r *SyncRequestResponse) UnmarshalJSON(data []byte) error

type SyncRequestResponseObject

type SyncRequestResponseObject string

Object type indicator

const (
	SyncRequestResponseObjectSyncRequest SyncRequestResponseObject = "sync_request"
)

type SyncRequestResponseStatus

type SyncRequestResponseStatus string

Current status of the sync request

const (
	SyncRequestResponseStatusQueued     SyncRequestResponseStatus = "queued"
	SyncRequestResponseStatusInProgress SyncRequestResponseStatus = "in_progress"
	SyncRequestResponseStatusCompleted  SyncRequestResponseStatus = "completed"
	SyncRequestResponseStatusFailed     SyncRequestResponseStatus = "failed"
)

type SyncService

type SyncService struct {
	Options []option.RequestOption
}

Change tracking for sync

SyncService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSyncService method instead.

func NewSyncService

func NewSyncService(opts ...option.RequestOption) (r SyncService)

NewSyncService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*SyncService) Request

func (r *SyncService) Request(ctx context.Context, body SyncRequestParams, opts ...option.RequestOption) (res *SyncRequestResponse, err error)

Request the client to sync a specific media item to the server.

The client will add the specified media item to its upload queue with high priority, uploading it to the server it's already connected to. This is used when a user clicks on an unsynced thumbnail in the server's gallery view.

type UsbConfigureParams

type UsbConfigureParams struct {
	// Whether the client should prefer USB over WiFi for uploads
	PreferUsb bool `json:"prefer_usb" api:"required"`
	// The USB tunnel URL that the client should use to connect to the server (e.g.,
	// http://localhost:51843)
	ServerURL string `json:"server_url" api:"required" format:"uri"`
	// contains filtered or unexported fields
}

func (UsbConfigureParams) MarshalJSON

func (r UsbConfigureParams) MarshalJSON() (data []byte, err error)

func (*UsbConfigureParams) UnmarshalJSON

func (r *UsbConfigureParams) UnmarshalJSON(data []byte) error

type UsbConfigureResponse

type UsbConfigureResponse struct {
	// Any of "usb_configure".
	Object UsbConfigureResponseObject `json:"object" api:"required"`
	// Whether USB is preferred
	PreferUsb bool `json:"prefer_usb" api:"required"`
	// The configured server URL
	ServerURL string `json:"server_url" api:"required"`
	// Whether the configuration was applied
	Success bool `json:"success" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Object      respjson.Field
		PreferUsb   respjson.Field
		ServerURL   respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (UsbConfigureResponse) RawJSON

func (r UsbConfigureResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*UsbConfigureResponse) UnmarshalJSON

func (r *UsbConfigureResponse) UnmarshalJSON(data []byte) error

type UsbConfigureResponseObject

type UsbConfigureResponseObject string
const (
	UsbConfigureResponseObjectUsbConfigure UsbConfigureResponseObject = "usb_configure"
)

type UsbService

type UsbService struct {
	Options []option.RequestOption
}

Connection management

UsbService contains methods and other services that help with interacting with the syncawesome API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewUsbService method instead.

func NewUsbService

func NewUsbService(opts ...option.RequestOption) (r UsbService)

NewUsbService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*UsbService) Configure

func (r *UsbService) Configure(ctx context.Context, body UsbConfigureParams, opts ...option.RequestOption) (res *UsbConfigureResponse, err error)

Notify the client about USB connection availability and provide the USB tunnel URL.

When the server establishes a USB tunnel to the client device, it calls this endpoint to inform the client that USB is available and provide the tunnel URL (typically http://localhost:PORT).

The client will update its connection preferences to use the USB tunnel for uploads instead of WiFi, significantly improving upload speeds (USB can reach 30MB/s+ vs WiFi's variable speeds).

func (*UsbService) Status

func (r *UsbService) Status(ctx context.Context, opts ...option.RequestOption) (res *UsbStatusResponse, err error)

Check whether the device is currently connected via USB. Does not require authentication.

type UsbStatusResponse

type UsbStatusResponse struct {
	// Whether device is connected via USB
	IsConnectedViaUsb bool `json:"is_connected_via_usb" api:"required"`
	// Any of "usb_status".
	Object UsbStatusResponseObject `json:"object" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		IsConnectedViaUsb respjson.Field
		Object            respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (UsbStatusResponse) RawJSON

func (r UsbStatusResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*UsbStatusResponse) UnmarshalJSON

func (r *UsbStatusResponse) UnmarshalJSON(data []byte) error

type UsbStatusResponseObject

type UsbStatusResponseObject string
const (
	UsbStatusResponseObjectUsbStatus UsbStatusResponseObject = "usb_status"
)

Directories

Path Synopsis
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
packages
shared

Jump to

Keyboard shortcuts

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