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: 10 Imported by: 0

README

Notes

Forum


DNS records (API)

GET: Get a list of all DNS records

ex: https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords

Query
The name of the parameter Description
dnsType dnsType query
content The Host value of the DNS record
Errors
type error Error code
ForbiddenError 1003
RateLimitExceeded 1013
Example
curl -X GET --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords
curl -X GET --user "api:api-MbmnxdpIBvk14nk5LFFdG1CV9PdMDfqi3tZAixBZLXYzM3qc187d7ede2de" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords \
-F dnsType="TXT" 
PUT: Creating a new DNS record on the desired website

ex: https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords

parameters
The name of the parameter Description
*type DNS record type [of types Aand AAAAand CNAMEand MXand NSand CAAand TXTand SPFand PTRand SRV]
*host The Host value of the DNS record
*content The Host value of the DNS record
ttl TTL of DNS record [default: 0]
cloud This parameter specifies whether the traffic of this record passes through the cloud or not [Default: false]
priority Priority of MX and SRV records [Default: 0]
service SRV record service
protocol SRV record protocol [default: _tcp]
weight SRV Record Weight [Default: 0]
port Priority of MX and SRV records [Default: 0]
advanced This parameter specifies whether this record has advanced settings or not [default: false]
upstreamPort Upstream Port of DNS record [Default: 80]
upstreamProtocol Upstream protocol related to DNS records. Note that if you change these settings for another record of the same subdomain, the settings will be overwritten. [Default: http]
customSSLType Custom SSL related DNS record. Note that if you change these settings for another record of the same subdomain, the settings will be overwritten.
Errors
type error Error code
ForbiddenError 1003
RateLimitExceeded 1013
DNSValidationError 1008
Example
curl -X PUT --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords  \
-F type="A"  \
-F host="app"  \
-F content="1.2.3.4"
GET: Get the information of a single DNS record

ex: https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords/:recordId

Errors
type error Error code
ForbiddenError 1003
RateLimitExceeded 1013
RecordNotFoundError 1021
Example
curl -X GET --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords/:recordId
PATCH: Edit the parameters of a DNS record

https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords/:recordId

parameters
The name of the parameter Description
type DNS record type [of types Aand AAAAand CNAMEand MXand NSand CAAand TXTand SPFand PTRand SRV]
host The Host value of the DNS record
content The Host value of the DNS record
ttl TTL of DNS record [default: 0]
cloud This parameter specifies whether the traffic of this record passes through the cloud or not [Default: false]
priority Priority of MX and SRV records [Default: 0]
service SRV record service
protocol SRV record protocol [default: _tcp]
weight SRV Record Weight [Default: 0]
port Priority of MX and SRV records [Default: 0]
advanced This parameter specifies whether this record has advanced settings or not [default: false]
upstreamPort Upstream Port of DNS record [Default: 80]
upstreamProtocol Upstream protocol related to DNS records. Note that if you change these settings for another record of the same subdomain, the settings will be overwritten. [Default: http]
customSSLType Custom SSL related DNS record. Note that if you change these settings for another record of the same subdomain, the settings will be overwritten.
Errors
type error Error code
ForbiddenError 1003
RateLimitExceeded 1013
RecordNotFoundError 1021
DNSValidationError 1008
Example
curl -X PATCH --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords/:recordId  \
-F cloud="true"
DELETE: Delete a DNS record

ex: https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords/:recordId

Errors
type error Error code
ForbiddenError 1003
RateLimitExceeded 1013
RecordNotFoundError 1021
Example
curl -X DELETE --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/dnsrecords/:recordId

Cache clearing (API)

POST: Clearing (Purge Cache) specified parameters, if no parameter is specified, the entire cache is deleted.

ex: https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/cache/purge

parameters
The name of the parameter Description
hostname The hostname to be deleted
hostnames An array of hostnames to be cleared
url The URL to be deleted
urls An array of URLs to be purged
Errors
type error Error code
ForbiddenError 1003
RateLimitExceeded 1013
Examples

Purge URLS:

curl -X POST --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/cache/purge  \
-F urls[]="https://www.derak.cloud/post/1"  \
-F urls[]="https://www.derak.cloud/post/2"

Purge HOSTNAMES:

curl -X POST --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/cache/purge  \
-F hostnames[]="www.derak.cloud"  \
-F hostnames[]="app.derak.cloud"

Purge EVERYTHING:

curl -X POST --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/cache/purge

API for SSL certificates

PUT: Enable SSL for a domain

ex: https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/ssl/

Errors
type error Error code
ForbiddenError 1003
Example
curl -X PUT --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/ssl/
DELETE: Disable SSL for a domain

ex: https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/ssl/

Errors
type error Error code
ForbiddenError 1003
Example
curl -X DELETE --user "api:YOUR_API_KEY" \
https://api.derak.cloud/v1.0/zones/47c0ecf6c91243308c649ad1d2d618dd/ssl/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse[T any] struct {
	Success bool `json:"success"`
	Result  T    `json:"result"`
	Error   int  `json:"error"`
}

type Client

type Client struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string) *Client

func (Client) CreateRecord

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

CreateRecord creates a new record.

func (Client) DeleteRecord

func (c Client) DeleteRecord(ctx context.Context, zoneID string, recordID string) error

DeleteRecord deletes an existing record.

func (Client) EditRecord

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

EditRecord edits an existing record.

func (Client) GetRecord

func (c Client) GetRecord(ctx context.Context, zoneID string, recordID string) (*Record, error)

GetRecord gets a record by ID.

func (Client) GetRecords

func (c Client) GetRecords(ctx context.Context, zoneID string, params *GetRecordsParameters) (*GetRecordsResponse, error)

GetRecords gets all records. Note: the response is not influenced by the query parameters, so the documentation seems wrong.

func (Client) GetZones

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

GetZones gets zones. Note: it's not a part of the official API, there is no documentation about this. The endpoint comes from UI calls analysis.

type GetRecordsParameters

type GetRecordsParameters struct {
	DNSType string `url:"dnsType,omitempty"`
	Content string `url:"content,omitempty"`
}

type GetRecordsResponse

type GetRecordsResponse struct {
	Data  []Record `json:"data"`
	Count int      `json:"count"`
}

type Record

type Record struct {
	Type    string `json:"type,omitempty"`
	Host    string `json:"host,omitempty"`
	Content string `json:"content,omitempty"`

	ID string `json:"recordId,omitempty"`

	TTL              int    `json:"ttl,omitempty"`
	Cloud            bool   `json:"cloud,omitempty"`
	Priority         int    `json:"priority,omitempty"`
	Service          string `json:"service,omitempty"`
	Protocol         string `json:"protocol,omitempty"`
	Weight           int    `json:"weight,omitempty"`
	Port             int    `json:"port,omitempty"`
	Advanced         bool   `json:"advanced,omitempty"`
	UpstreamPort     int    `json:"upstreamPort,omitempty"`
	UpstreamProtocol string `json:"upstreamProtocol,omitempty"`
	CustomSSLType    string `json:"customSSLType,omitempty"`
}

type Zone

type Zone struct {
	ID               string    `json:"zoneId,omitempty"`
	Tags             []string  `json:"tags,omitempty"`
	ContextID        string    `json:"contextId,omitempty"`
	ContextType      string    `json:"contextType,omitempty"`
	HumanReadable    string    `json:"humanReadable,omitempty"`
	Serial           string    `json:"serial,omitempty"`
	CreationTime     int64     `json:"creationTime,omitempty"`
	CreationTimeDate time.Time `json:"creationTimeDate,omitempty"`
	Status           string    `json:"status,omitempty"`
	IsMoved          bool      `json:"is_moved,omitempty"`
	Paused           bool      `json:"paused,omitempty"`
	ServiceType      string    `json:"serviceType,omitempty"`
	Limbo            bool      `json:"limbo,omitempty"`
	TeamName         string    `json:"teamName,omitempty"`
	TeamID           string    `json:"teamId,omitempty"`
	MyTeam           bool      `json:"myTeam,omitempty"`
	RoleName         string    `json:"roleName,omitempty"`
	IsBoard          bool      `json:"isBoard,omitempty"`
	BoardRole        []string  `json:"boardRole,omitempty"`
}

Jump to

Keyboard shortcuts

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