mch

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ConnectionRecheckTime = 30 * time.Second
View Source
const DirectoryMimeType = "application/x.wd.dir"
View Source
const FileFields = "id,eTag,parentID,childCount,mimeType,name,size,mTime,cTime"

Variables

View Source
var ErrorInvalidOperation = errors.New("invalid operation")
View Source
var ErrorUnexpectedStatusCode = errors.New("unexpected status code")

Functions

This section is empty.

Types

type Client

type Client struct {
	AccessToken   string         `json:"access_token"`
	RefreshToken  string         `json:"refresh_token"`
	IDToken       string         `json:"id_token"`
	Scope         string         `json:"scope"`
	TokenType     string         `json:"token_type"`
	ExpiresIn     int            `json:"expires_in"`
	UserID        string         `json:"user_id,omitempty"`
	Configuration *Configuration `json:"configuration,omitempty"`
	OSType        string         `json:"os_type,omitempty"`
	HTTPClient    http.Client    `json:"-"`
}

func Login

func Login(username string, password string) (*Client, error)

func (*Client) DeviceInfo

func (c *Client) DeviceInfo() (*DeviceInfo, error)

func (*Client) NewAuthorizedRequest

func (c *Client) NewAuthorizedRequest(method, url string, body io.Reader) (*http.Request, error)

type Configuration

type Configuration struct {
	ConfigurationID string                            `json:"configurationId"`
	ComponentMap    map[string]map[string]interface{} `json:"componentMap"`
}

func GetConfiguration

func GetConfiguration() (*Configuration, error)

func (Configuration) GetString

func (c Configuration) GetString(section, config string) string

type Device

type Device struct {
	DeviceID             string        `json:"deviceId"`
	Name                 string        `json:"name"`
	Mac                  string        `json:"mac"`
	DeviceType           string        `json:"type"`
	CreatedOn            ISOTime       `json:"createdOn"`
	AttachedStatus       string        `json:"attachedStatus"`
	Lang                 string        `json:"lang"`
	Network              DeviceNetwork `json:"network"`
	LastHDStoragePercent int           `json:"lastHDStoragePercent"`
	CloudConnected       bool          `json:"cloudConnected"`
	OwnerAccess          bool          `json:"ownerAccess"`
	SerialNumber         string        `json:"serialNumber"`
	APIVersion           string        `json:"apiVersion"`
	// contains filtered or unexported fields
}

func (*Device) DeviceURI added in v0.1.0

func (d *Device) DeviceURI() string

func (*Device) GetFileByPath

func (d *Device) GetFileByPath(path string) (*File, error)

func (*Device) Root

func (d *Device) Root() (*File, error)

type DeviceConnectionMode added in v0.1.0

type DeviceConnectionMode int

DeviceConnectionMode represents the current connection status for a device.

const (
	UnknownConnection DeviceConnectionMode = iota
	InternalConnection
	ExternalConnection
)

func (DeviceConnectionMode) String added in v0.1.0

func (dm DeviceConnectionMode) String() string

type DeviceInfo

type DeviceInfo struct {
	Data []Device `json:"data"`
	// contains filtered or unexported fields
}

func (DeviceInfo) Find

func (di DeviceInfo) Find(name string) *Device

type DeviceNetwork

type DeviceNetwork struct {
	LocalIPAddress              net.IP `json:"localIpAddress"`
	ExternalIPAddress           net.IP `json:"externalIpAddress"`
	LocalHTTPPort               int    `json:"localHttpPort"`
	LocalHTTPSPort              int    `json:"localHttpsPort"`
	PortForwardPort             int    `json:"portForwardPort"`
	TunnelID                    string `json:"tunnelId"`
	InternalDNSName             string `json:"internalDNSName"`
	InternalURL                 string `json:"internalURL"`
	PortForwardURL              string `json:"portForwardURL"`
	PortForwardDomain           string `json:"portForwardDomain"`
	ProxyURL                    string `json:"proxyURL"`
	ExternalURI                 string `json:"externalURI"`
	PortForwardInfoUpdateStatus string `json:"portForwardInfoUpdateStatus"`
}

type File

type File struct {
	ID         string  `json:"id"`
	ETag       string  `json:"eTag"`
	ParentID   string  `json:"parentID"`
	ChildCount int     `json:"childCount,omitempty"`
	MimeType   string  `json:"mimeType"`
	Name       string  `json:"name"`
	Size       uint64  `json:"size,omitempty"`
	MTime      ISOTime `json:"mTime"`
	CTime      ISOTime `json:"cTime"`
	// contains filtered or unexported fields
}

func (*File) Create

func (f *File) Create(name string) (*File, error)

func (*File) CreateDirectory

func (f *File) CreateDirectory(name string) (*File, error)

func (*File) Delete

func (f *File) Delete() error

func (*File) IsDirectory

func (f *File) IsDirectory() bool

func (*File) ListDirectory

func (f *File) ListDirectory() (map[string]File, error)

func (*File) LookupDirectory

func (f *File) LookupDirectory(name string) (*File, error)

func (*File) Read

func (f *File) Read(dest []byte, offset int64) (int, error)

func (*File) Refresh

func (f *File) Refresh() error

func (*File) Rename

func (f *File) Rename(newParent *File, newName string) error

func (*File) SetMeta

func (f *File) SetMeta(reqJSON map[string]interface{}) error

func (*File) Truncate

func (f *File) Truncate(offset int64) error

func (*File) Write

func (f *File) Write(data []byte, offset int64) error

type FileList

type FileList struct {
	Files     []File `json:"files"`
	PageToken string `json:"pageToken"`
	ETag      string `json:"eTag"`
	// contains filtered or unexported fields
}

type ISOTime

type ISOTime time.Time

func (ISOTime) MarshalJSON

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

func (ISOTime) String

func (t ISOTime) String() string

func (*ISOTime) UnmarshalJSON

func (t *ISOTime) UnmarshalJSON(input []byte) error

type MultipartBody

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

func NewMultipartBody

func NewMultipartBody(reqJSON interface{}) (*MultipartBody, error)

func (MultipartBody) AddContentType

func (mb MultipartBody) AddContentType(req *http.Request)

func (MultipartBody) Buffer

func (mb MultipartBody) Buffer() *bytes.Buffer

Jump to

Keyboard shortcuts

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