synologyapi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 14 Imported by: 0

README

synology_api_go

A wrapper of Synology api written in Go

Credit

  1. Inspired from https://github.com/N4S4/synology-api

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGetApiInfo error = errors.New("there was a problem while getting the api spec from your synology")
)

Functions

This section is empty.

Types

type ApiEndpoint

type ApiEndpoint struct {
	Host string
	Port int
	SSL  bool
}

type AuthenticateApi

type AuthenticateApi interface {
	Login(credential models.ApiCredential) (apiCredentialState, error)
	Logout(credentialState *apiCredentialState) error
}

func NewAuthenticate

func NewAuthenticate(baseApi *BaseApi) AuthenticateApi

type BaseApi

type BaseApi struct {
	HttpClient  *http.Client
	ApiEndpoint *ApiEndpoint

	ApiInfo models.ApiInfo
	// contains filtered or unexported fields
}

func (*BaseApi) GetNewHttpRequest

func (b *BaseApi) GetNewHttpRequest(httpMethod HttpMethod, api string, body io.Reader) (*http.Request, error)

func (*BaseApi) SendRequest

func (b *BaseApi) SendRequest(req *http.Request, targetResponse any) error

func (*BaseApi) SetApiCredentialState

func (b *BaseApi) SetApiCredentialState(credentialState *apiCredentialState)

type CertificateApi

type CertificateApi interface {
	ListCertificate() error
	UploadCertificate(uploadDetail CertificateUploadDetail) error
}

func NewCertificate

func NewCertificate(baseApi *BaseApi) CertificateApi

type CertificateUploadDetail

type CertificateUploadDetail struct {
	Certificate             string `form:"cert" contentType:"application/x-x509-ca-cert" filename:"cert.cert"`
	PrivateKey              string `form:"key" contentType:"application/octet-stream" filename:"key.key"`
	IntermediateCertificate string `form:"inter_cert" omitempty:"true"`
	SetDefault              string `form:"as_default" default:"False"`
	Id                      string `form:"id"`
	Desc                    string `form:"desc"`
}

type HttpMethod

type HttpMethod string
const (
	GET  HttpMethod = "GET"
	POST HttpMethod = "POST"
)

type InfoApi

type InfoApi interface {
	GetApisInfo() (*models.Response[models.ApiInfo], error)
}

func NewInfo

func NewInfo(baseApi BaseApi) InfoApi

type SynologyApi

type SynologyApi interface {
	Authenticate() AuthenticateApi
	Info() InfoApi
	Certificate() CertificateApi
	SetApiCredentialState(credentialState *apiCredentialState)
}

func NewSynologyApi

func NewSynologyApi(apiEndpoint *ApiEndpoint) (SynologyApi, error)

A Facade pattern, Every one should create this instance before usage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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