internal

package
v4.17.6 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIBaseURL  = "https://console.cloud.ru/api/clouddns/v1"
	AuthBaseURL = "https://auth.iam.cloud.ru/auth/system/openid/token"
)

Default API endpoints.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse[T any] struct {
	Items []T `json:"items"`
}

type Client

type Client struct {
	APIEndpoint  *url.URL
	AuthEndpoint *url.URL
	HTTPClient   *http.Client
	// contains filtered or unexported fields
}

Client the Cloud.ru API client.

func NewClient

func NewClient(login, secret string) *Client

NewClient Creates a new Client.

func (*Client) CreateAuthenticatedContext

func (c *Client) CreateAuthenticatedContext(ctx context.Context) (context.Context, error)

func (*Client) CreateRecord

func (c *Client) CreateRecord(ctx context.Context, zoneID string, record Record) (*Record, error)

func (*Client) DeleteRecord

func (c *Client) DeleteRecord(ctx context.Context, zoneID, name, recordType string) error

func (*Client) GetRecords

func (c *Client) GetRecords(ctx context.Context, zoneID string) ([]Record, error)

func (*Client) GetZones

func (c *Client) GetZones(ctx context.Context, parentID string) ([]Zone, error)

type Record

type Record struct {
	ZoneID  string   `json:"zone_id,omitempty"`
	Name    string   `json:"name,omitempty"`
	Type    string   `json:"type,omitempty"`
	Values  []string `json:"values,omitempty"`
	TTL     string   `json:"ttl,omitempty"`
	Enables bool     `json:"enables,omitempty"`
}

type Token

type Token struct {
	// The bearer token for use in API requests
	AccessToken string `json:"access_token"`
	TokenID     string `json:"id_token"`
	TokenType   string `json:"token_type"`
	// Number in seconds before the expiration
	ExpiresIn       int    `json:"expires_in"`
	NotBeforePolicy int    `json:"not-before-policy"`
	Scope           string `json:"scope"`

	Deadline time.Time `json:"-"`
}

type Zone

type Zone struct {
	ID             string    `json:"id,omitempty"`
	ParentID       string    `json:"parent_id,omitempty"`
	Name           string    `json:"name,omitempty"`
	Valid          bool      `json:"valid,omitempty"`
	ValidationText string    `json:"validationText,omitempty"`
	Delegated      bool      `json:"delegated,omitempty"`
	LastCheck      time.Time `json:"lastCheck,omitempty"`
	CreatedAt      time.Time `json:"created_at,omitempty"`
	UpdatedAt      time.Time `json:"updated_at,omitempty"`
}

Jump to

Keyboard shortcuts

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