client

package module
v0.0.0-...-ad012dd Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 16 Imported by: 0

README

Synology API Go client

Synology-go is a Go library for accessing Synology DSM system via HTTP API.

Install

go get github.com/maksym-nazarenko/terraform-provider-synology/synology-go@v0.0.1

or

go get github.com/maksym-nazarenko/terraform-provider-synology/synology-go

for the latest version.

Usage

package main

import (
	"log"

	"github.com/maksym-nazarenko/terraform-provider-synology/synology-go/api"
	"github.com/maksym-nazarenko/terraform-provider-synology/synology-go/api/filestation"
)

func main() {
	skipCertificateVerification := true
	c, err := New("synology-server:5001", skipCertificateVerification)
	if err != nil {
		log.Fatal(err)
	}

	if err := c.Login("api-client", "password", "webui"); err != nil {
		log.Fatal(err)
	}

	req := filestation.NewCreateFolderRequest(2).
		WithFolderPath("/test-folder").
		WithName("folder_name")

	resp := filestation.CreateFolderResponse{}
	err = c.Do(r, &resp)
	if err != nil {
		log.Fatal(err)
	}

	if !resp.Success() {
		log.Fatal(resp.GetError())
	}

	log.Printf("Created %d folder(s)\n", len(resp.Folders))
}

Supported APIs

API Min version Method Description
SYNO.FileStation.CreateFolder 2 create Create folders
SYNO.FileStation.Info 2 get Provide File Station information
SYNO.FileStation.Rename 2 rename Rename a file/folder

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Login(user, password, sessionName string) error
	Do(r api.Request, response api.Response) error
}

func New

func New(host string, skipCertificateVerification bool) (Client, error)

New initializes "client" instance with minimal input configuration.

Directories

Path Synopsis
api
Package api provides types for common objects required during calls to remote Synology instance.
Package api provides types for common objects required during calls to remote Synology instance.

Jump to

Keyboard shortcuts

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