arvancloud

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// SCHEME is the scheme used to connect to the ArvanCloud API
	SCHEME = "https"

	// HOST_NAME is the host name used to connect to the ArvanCloud API
	HOST_NAME = "napi.arvancloud.ir"

	// BASE_PATH is the base path used to connect to the CDN API
	BASE_PATH = "/cdn/4.0"

	// UA is the user agent of client
	UA = "r1c-go"

	// VERSION is the version of client
	VERSION = "v0.1.3"
)

Variables

View Source
var (
	ErrMissingDomain      = errors.New(errMissingDomain)
	ErrMissingDNSRecordID = errors.New(errMissingDNSRecordID)
)

Functions

func PrettyPrint

func PrettyPrint(data interface{})

PrettyPrint will print the contents of the object

Types

type API

type API struct {
	APIKey    string
	APIEmail  string
	BaseURL   string
	UserAgent string

	Debug bool
	// contains filtered or unexported fields
}

func New

func New(token string, opts ...Option) (*API, error)

New creates a new instance of the API client with the given API token and options.

func (*API) CreateDNSRecord

func (api *API) CreateDNSRecord(ctx context.Context, resource Resource, record CreateDNSRecordParams) (res *CreateDNSRecord_Response, err error)

CreateDNSRecord will create a DNS record ? Documentation: https://www.arvancloud.ir/api/cdn/4.0#tag/DNS-Management/operation/dns_records.store

func (*API) DeleteDNSRecord

func (api *API) DeleteDNSRecord(ctx context.Context, resource Resource, recordID string) (*DeleteDNSRecord_Response, error)

DeleteDNSRecord will delete a DNS record ? Documentation: https://www.arvancloud.ir/api/cdn/4.0#tag/DNS-Management/operation/dns_records.remove

func (*API) GetDNSRecord

func (api *API) GetDNSRecord(ctx context.Context, resource Resource, recordID string) (*DNSRecord, error)

GetDNSRecord will return a single DNS record ? Documentation: https://www.arvancloud.ir/api/cdn/4.0#tag/DNS-Management/operation/dns_records.show

func (*API) ListDNSRecords

func (api *API) ListDNSRecords(ctx context.Context, resource Resource, params ListDNSRecordsParams) ([]DNSRecord, error)

ListDNSRecords will list a part of DNS records ? Documentation: https://www.arvancloud.ir/api/cdn/4.0#tag/DNS-Management/operation/dns_records.list

func (*API) UpdateDNSRecord

func (api *API) UpdateDNSRecord(ctx context.Context, resource Resource, recordID string, params UpdateDNSRecordParams) (*UpdateDNSRecord_Response, error)

UpdateDNSRecord will update a DNS record ? Documentation: https://www.arvancloud.ir/api/cdn/4.0#tag/DNS-Management/operation/dns_records.update

type CreateDNSRecordParams

type CreateDNSRecordParams struct {
	Type          string      `json:"type,omitempty"`
	Name          string      `json:"name,omitempty"`
	Value         interface{} `json:"value,omitempty"`
	TTL           int         `json:"ttl,omitempty"`
	Cloud         bool        `json:"cloud,omitempty"`
	UpstreamHTTPS string      `json:"upstream_https,omitempty"`
	IPFilterMode  interface{} `json:"ip_filter_mode,omitempty"`
}

CreateDNSRecordParams is a structure for all needed parameters to create DNS record

type CreateDNSRecord_Response

type CreateDNSRecord_Response struct {
	Message string              `json:"message,omitempty"`
	Status  bool                `json:"status,omitempty"`
	Errors  map[string][]string `json:"errors,omitempty"`
	Data    interface{}         `json:"data,omitempty"`
}

CreateDNSRecord_Response is a response structure when creating a DNS record of a domain

type DNSRecord

type DNSRecord struct {
	ID            string      `json:"id,omitempty"`
	Type          string      `json:"type,omitempty"`
	Name          string      `json:"name,omitempty"`
	Value         interface{} `json:"value,omitempty"`
	TTL           int         `json:"ttl,omitempty"`
	Cloud         bool        `json:"cloud,omitempty"`
	UpstreamHTTPS string      `json:"upstream_https,omitempty"`
	IPFilterMode  interface{} `json:"ip_filter_mode,omitempty"`
	IsProtected   bool        `json:"is_protected,omitempty"`
	CreatedAt     string      `json:"created_at,omitempty"`
	UpdatedAt     string      `json:"updated_at,omitempty"`
}

DSNRecord is a DSN record structure for a domain

type DNSRecord_IPFilterMode

type DNSRecord_IPFilterMode struct {
	Count     string `json:"count,omitempty"`
	Order     string `json:"order,omitempty"`
	GeoFilter string `json:"geo_filter,omitempty"`
}

DNSRecord_IPFilterMode is a structure for IP Filter Mode when creating a DNS record

type DNSRecord_Response

type DNSRecord_Response struct {
	Data DNSRecord `json:"data,omitempty"`
}

DNSRecord_Response is response structure contains DSN record's data

type DNSRecord_Value_A

type DNSRecord_Value_A struct {
	IP      string `json:"ip,omitempty"`
	Port    int    `json:"port,omitempty"`
	Weight  int    `json:"weight,omitempty"`
	Country string `json:"country,omitempty"`
}

DNSRecord_Value_A is a structure for A record

type DNSRecord_Value_AAAA

type DNSRecord_Value_AAAA = DNSRecord_Value_A

DNSRecord_Value_AAAA is a structure for AAAA record

type DNSRecord_Value_ANAME

type DNSRecord_Value_ANAME struct {
	Location   string `json:"location,omitempty"`
	HostHeader string `json:"host_header,omitempty"`
	Port       int    `json:"port,omitempty"`
}

DNSRecord_Value_ANAME is a structure for ANAME record

type DNSRecord_Value_CAA

type DNSRecord_Value_CAA struct {
	Value string `json:"value,omitempty"`
	Tag   string `json:"tag,omitempty"`
}

DNSRecord_Value_CAA is a structure for CAA record

type DNSRecord_Value_CNAME

type DNSRecord_Value_CNAME struct {
	Host       string `json:"host,omitempty"`
	HostHeader string `json:"host_header,omitempty"`
	Port       int    `json:"port,omitempty"`
}

DNSRecord_Value_CNAME is a structure for CNAME record

type DNSRecord_Value_DKIM

type DNSRecord_Value_DKIM = DNSRecord_Value_TXT

DNSRecord_Value_DKIM is a structure for DKIM record

type DNSRecord_Value_MX

type DNSRecord_Value_MX struct {
	Host     string `json:"host,omitempty"`
	Priority int    `json:"priority,omitempty"`
}

DNSRecord_Value_MX is a structure for MX record

type DNSRecord_Value_NS

type DNSRecord_Value_NS struct {
	Host string `json:"host,omitempty"`
}

DNSRecord_Value_NS is a structure for NS record

type DNSRecord_Value_PTR

type DNSRecord_Value_PTR struct {
	Domain string `json:"domain,omitempty"`
}

DNSRecord_Value_PTR is a structure for PTR record

type DNSRecord_Value_SPF

type DNSRecord_Value_SPF = DNSRecord_Value_TXT

DNSRecord_Value_SPF is a structure for SPF record

type DNSRecord_Value_SRV

type DNSRecord_Value_SRV struct {
	Target   string `json:"target,omitempty"`
	Port     int    `json:"port,omitempty"`
	Weight   int    `json:"weight,omitempty"`
	Priority int    `json:"priority,omitempty"`
}

DNSRecord_Value_SRV is a structure for SRV record

type DNSRecord_Value_TLSA

type DNSRecord_Value_TLSA struct {
	Usage        string `json:"usage,omitempty"`
	Selector     string `json:"selector,omitempty"`
	MatchingType string `json:"matching_type,omitempty"`
	Certificate  string `json:"certificate,omitempty"`
}

DNSRecord_Value_TLSA is a structure for TLSA record

type DNSRecord_Value_TXT

type DNSRecord_Value_TXT struct {
	Text string `json:"text,omitempty"`
}

DNSRecord_Value_TXT is a structure for TXT record

type DeleteDNSRecord_Response

type DeleteDNSRecord_Response = CreateDNSRecord_Response

DeleteDNSRecord_Response is a response structure when deleting a DNS record of a domain

type Error

type Error struct {
	// The classification of error encountered.
	Type ErrorType

	// StatusCode is the HTTP status code from the response.
	Code int

	// Message is the error message.
	Message string

	// Errors is a list of all the response error.
	Errors map[string][]string
}

Error is the error returned by the ArvanCloud API.

func (Error) Error

func (e Error) Error() string

Error will return a human readable error message.

type ErrorType

type ErrorType string
const (
	ErrorTypeRequest        ErrorType = "request"
	ErrorTypeAuthentication ErrorType = "authentication"
	ErrorTypeAuthorization  ErrorType = "authorization"
	ErrorTypeNotFound       ErrorType = "not_found"
	ErrorTypeRateLimit      ErrorType = "rate_limit"
	ErrorTypeService        ErrorType = "service"
)

type ListDNSRecord_Response

type ListDNSRecord_Response struct {
	Data  []DNSRecord `json:"data"`
	Meta  interface{} `json:"meta,omitempty"`
	Links interface{} `json:"links,omitempty"`
}

ListDNSRecord_Response is a response structure when listing DNS records of a domain

type ListDNSRecordsParams

type ListDNSRecordsParams struct {
	Search  string `url:"search,omitempty"`
	Type    string `url:"type,omitempty"`
	Page    int    `url:"page,omitempty"`
	PerPage int    `url:"per_page,omitempty"`
}

ListDNSRecordsParams is a structure for all needed parameters to list all DNS records of a domain

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

type Option

type Option func(*API) error

func Debug

func Debug(debug bool) Option

Debug will handle debugging mode for API client

func Headers

func Headers(headers http.Header) Option

Headers will set custom HTTP headers for API calls

func UserAgent

func UserAgent(userAgent string) Option

UsingLogger will apply a custom user agent to API client

func UsingRateLimit

func UsingRateLimit(rps float64) Option

UsingRateLimit will apply a rate limit policy to API client

func UsingRetryPolicy

func UsingRetryPolicy(maxRetries int, minRetryDelaySecs int, maxRetryDelaySecs int) Option

UsingRetryPolicy will apply a retry policy to API client

type RequestError

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

RequestError is for 4xx errors.

func NewRequestError

func NewRequestError(e *Error) RequestError

NewRequestError will return a new RequestError.

func (RequestError) Error

func (e RequestError) Error() string

Error will return a human readable error message.

func (RequestError) ErrorCode

func (e RequestError) ErrorCode() int

ErrorCode will return the HTTP status code.

func (RequestError) ErrorMessage

func (e RequestError) ErrorMessage() string

ErrorMessage will return the error message.

func (RequestError) Errors

func (e RequestError) Errors() map[string][]string

Errors will return a map of all the errors.

func (RequestError) Type

func (e RequestError) Type() ErrorType

Type will return the error type.

type Resource

type Resource struct {
	Domain string
}

func ResourceDomain

func ResourceDomain(domain string) Resource

type RetryPolicy

type RetryPolicy struct {
	MaxRetries    int
	MinRetryDelay time.Duration
	MaxRetryDelay time.Duration
}

type ServiceError

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

ServiceError is for 5xx errors.

func NewServiceError

func NewServiceError(e *Error) ServiceError

NewServiceError will return a new ServiceError.

func (ServiceError) Error

func (e ServiceError) Error() string

Error will return a human readable error message.

func (ServiceError) ErrorCode

func (e ServiceError) ErrorCode() int

ErrorCode will return the HTTP status code.

func (ServiceError) ErrorMessage

func (e ServiceError) ErrorMessage() string

ErrorMessage will return the error message.

func (ServiceError) Errors

func (e ServiceError) Errors() map[string][]string

Errors will return a map of all the errors.

func (ServiceError) Type

func (e ServiceError) Type() ErrorType

Type will return the error type.

type UpdateDNSRecordParams

type UpdateDNSRecordParams = CreateDNSRecordParams

type UpdateDNSRecord_Response

type UpdateDNSRecord_Response = CreateDNSRecord_Response

UpdateDNSRecord_Response is a response structure when updating a DNS record of a domain

Jump to

Keyboard shortcuts

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