myrasec

package module
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 10 Imported by: 1

README

myrasec-go

Go Report Card Go Reference

A Go library for interacting with Myra Security API.

Note: This library is under active development. Upcoming changes may break existing functionality. Consider this library as unstable.

Documentation

Documentation

Index

Constants

View Source
const (
	ParamPage     = "page"
	ParamPageSize = "pageSize"
	ParamSearch   = "search"
)
View Source
const (
	// APIBaseURL ...
	APIBaseURL = "https://api.myracloud.com/%s/rapi/%s"
	// DefaultAPILanguage ...
	DefaultAPILanguage = "en"
	// DefaultAPIUserAgent ...
	DefaultAPIUserAgent = "myrasec-go"
)

Variables

View Source
var APILanguages = map[string]bool{
	"en": true,
	"de": true,
}

APILanguages ...

Functions

This section is empty.

Types

type API

type API struct {
	BaseURL   string
	Language  string
	UserAgent string
	// contains filtered or unexported fields
}

API holds the configuration for the current API client.

func New

func New(key, secret string) (*API, error)

New returns a new MYRA API Client

func (*API) CreateCacheSetting

func (api *API) CreateCacheSetting(setting *CacheSetting, subDomainName string) (*CacheSetting, error)

CreateCacheSetting creates a new cache setting for the passed subdomain (name) using the MYRA API

func (*API) CreateDNSRecord

func (api *API) CreateDNSRecord(record *DNSRecord, domainName string) (*DNSRecord, error)

CreateDNSRecord creates a new DNS record using the MYRA API

func (*API) CreateDomain

func (api *API) CreateDomain(domain *Domain) (*Domain, error)

CreateDomain creates a new domain using the MYRA API

func (*API) CreateIPFilter

func (api *API) CreateIPFilter(filter *IPFilter, subDomainName string) (*IPFilter, error)

CreateIPFilter creates a new ip filter for the passed subdomain (name) using the MYRA API

func (*API) CreateRateLimit

func (api *API) CreateRateLimit(ratelimit *RateLimit) (*RateLimit, error)

CreateRateLimit creates a new rate limit setting for the passed subdomain (name) using the MYRA API

func (*API) CreateRedirect

func (api *API) CreateRedirect(redirect *Redirect, subDomainName string) (*Redirect, error)

CreateRedirect creates a new redirect for the passed subdomain (name) using the MYRA API

func (*API) CreateSSLCertificate added in v1.7.0

func (api *API) CreateSSLCertificate(cert *SSLCertificate, domainName string) (*SSLCertificate, error)

CreateSSLCertificate creates a new SSL certificates on the passed domain (name) using the MYRA API

func (*API) CreateWAFRule added in v1.3.0

func (api *API) CreateWAFRule(rule *WAFRule) (*WAFRule, error)

CreateWAFRule creates a new WAF rule

func (*API) DeleteCacheSetting

func (api *API) DeleteCacheSetting(setting *CacheSetting, subDomainName string) (*CacheSetting, error)

DeleteCacheSetting deletes the passed cache setting using the MYRA API

func (*API) DeleteDNSRecord

func (api *API) DeleteDNSRecord(record *DNSRecord, domainName string) (*DNSRecord, error)

DeleteDNSRecord deletes the passed DNS record using the MYRA API

func (*API) DeleteDomain

func (api *API) DeleteDomain(domain *Domain) (*Domain, error)

DeleteDomain deletes the passed domain using the MYRA API

func (*API) DeleteIPFilter

func (api *API) DeleteIPFilter(filter *IPFilter, subDomainName string) (*IPFilter, error)

DeleteIPFilter deletes the passed ip filter using the MYRA API

func (*API) DeleteRateLimit

func (api *API) DeleteRateLimit(ratelimit *RateLimit) (*RateLimit, error)

DeleteRateLimit deletes the passed rate limit setting using the MYRA API

func (*API) DeleteRedirect

func (api *API) DeleteRedirect(redirect *Redirect, subDomainName string) (*Redirect, error)

DeleteRedirect deletes the passed redirect using the MYRA API

func (*API) DeleteSSLCertificate added in v1.7.0

func (api *API) DeleteSSLCertificate(cert *SSLCertificate, domainName string) (*SSLCertificate, error)

DeleteSSLCertificate "deletes" the passed SSL certificate by removing the assigned subdomains from the certificate using the MYRA API

func (*API) DeleteWAFRule added in v1.3.0

func (api *API) DeleteWAFRule(rule *WAFRule) (*WAFRule, error)

DeleteWAFRule deletes the passed WAF rule

func (*API) FetchWAFRule added in v1.3.0

func (api *API) FetchWAFRule(id int, params map[string]string) (*WAFRule, error)

FetchWAFRule returns a single WAF rule for the given ID

func (*API) ListCacheSettings

func (api *API) ListCacheSettings(subDomainName string, params map[string]string) ([]CacheSetting, error)

ListCacheSettings returns a slice containing all visible cache settings for a subdomain

func (*API) ListDNSRecords

func (api *API) ListDNSRecords(domainName string, params map[string]string) ([]DNSRecord, error)

ListDNSRecords returns a slice containing all visible DNS records for a domain

func (*API) ListDomains

func (api *API) ListDomains(params map[string]string) ([]Domain, error)

ListDomains returns a slice containing all visible domains

func (*API) ListIPFilters

func (api *API) ListIPFilters(subDomainName string, params map[string]string) ([]IPFilter, error)

ListIPFilters returns a slice containing all visible ip filters for a subdomain

func (*API) ListIPRanges added in v1.5.0

func (api *API) ListIPRanges(params map[string]string) ([]IPRange, error)

ListIPRanges returns a slice containing all ip ranges

func (*API) ListRateLimits

func (api *API) ListRateLimits(rateLimitType string, params map[string]string) ([]RateLimit, error)

ListRateLimits returns a slice containing all visible rate limit settings Valid rateLimitType values are "dns" or "tag"

Rate limit settings can be filtered using the params map

Avalilable filters/query parameters:

search (string) - filter by the specified search query

Additional valid filters/query parameters for ruleType = "dns":

subDomainName (string) - filter rate limit settings for this subdomain (name)
reference (int) - filter rate limit settings for this domain (ID)

Additional valid filters/query parameters for ruleType = "tag":

reference (int) - filter rate limit settings for this tag (ID)

func (*API) ListRedirects

func (api *API) ListRedirects(subDomainName string, params map[string]string) ([]Redirect, error)

ListRedirects returns a slice containing all visible redirects for a subdomain

func (*API) ListSSLCertificates added in v1.7.0

func (api *API) ListSSLCertificates(domainName string, params map[string]string) ([]SSLCertificate, error)

ListSSLCertificates returns a slice containing all visible SSL certificates for a domain

func (*API) ListSettings

func (api *API) ListSettings(subDomainName string, params map[string]string) (*Settings, error)

ListSettings returns a Setting struct containing the settings for the passed subdomain

func (*API) ListWAFActions added in v1.3.0

func (api *API) ListWAFActions() ([]WAFAction, error)

ListWAFActions returns a list of available WAF actions

func (*API) ListWAFConditions added in v1.3.0

func (api *API) ListWAFConditions() ([]WAFCondition, error)

ListWAFConditions returns a list of available WAF conditions

func (*API) ListWAFRules added in v1.3.0

func (api *API) ListWAFRules(ruleType string, params map[string]string) ([]WAFRule, error)

ListWAFRules returns a list of WAF rules. Valid ruleType values are "domain", "tag" or "template"

Rules can be filtered using the params map

Avalilable filters/query parameters:

search (string) - filter by the specified search query

Additional valid filters/query parameters for ruleType = "domanin":

domainName (string) - filter WAF rules for this domain (name)
domain (int) - filter WAF rules for this domain (ID)
subDomain (string) - filter WAF rules for this subdomain (name)

Additional valid filters/query parameters for ruleType = "tag":

tagId (int) - filter WAF rules for this tag (ID)

func (*API) SetLanguage

func (api *API) SetLanguage(language string) error

SetLanguage changes the API language.

func (*API) SetUserAgent

func (api *API) SetUserAgent(userAgent string)

SetUserAgent sets the User-Agent for the API.

func (*API) UpdateCacheSetting

func (api *API) UpdateCacheSetting(setting *CacheSetting, subDomainName string) (*CacheSetting, error)

UpdateCacheSetting updates the passed cache setting using the MYRA API

func (*API) UpdateDNSRecord

func (api *API) UpdateDNSRecord(record *DNSRecord, domainName string) (*DNSRecord, error)

UpdateDNSRecord updates the passed DNS record using the MYRA API

func (*API) UpdateDomain

func (api *API) UpdateDomain(domain *Domain) (*Domain, error)

UpdateDomain updates the passed domain using the MYRA API

func (*API) UpdateIPFilter

func (api *API) UpdateIPFilter(filter *IPFilter, subDomainName string) (*IPFilter, error)

UpdateIPFilter updates the passed ip filter using the MYRA API

func (*API) UpdateRateLimit

func (api *API) UpdateRateLimit(ratelimit *RateLimit) (*RateLimit, error)

UpdateRateLimit updates the passed rate limit setting using the MYRA API

func (*API) UpdateRedirect

func (api *API) UpdateRedirect(redirect *Redirect, subDomainName string) (*Redirect, error)

UpdateRedirect updates the passed redirect using the MYRA API

func (*API) UpdateSSLCertificate added in v1.7.0

func (api *API) UpdateSSLCertificate(cert *SSLCertificate, domainName string) (*SSLCertificate, error)

UpdateSSLCertificate updates the passed SSL certificate using the MYRA API

func (*API) UpdateSettings

func (api *API) UpdateSettings(settings *Settings, subDomainName string) (*Settings, error)

UpdateSettings updates the passed settings using the MYRA API

func (*API) UpdateWAFRule added in v1.3.0

func (api *API) UpdateWAFRule(rule *WAFRule) (*WAFRule, error)

UpdateWAFRule updates the passed WAF rule

type APIMethod

type APIMethod struct {
	Name               string
	Action             string
	Method             string
	Result             interface{}
	ResponseDecodeFunc func(resp *http.Response, definition APIMethod) (interface{}, error)
}

APIMethod represents API call definitions used in the methods map

type CacheSetting

type CacheSetting struct {
	ID          int             `json:"id,omitempty"`
	Created     *types.DateTime `json:"created,omitempty"`
	Modified    *types.DateTime `json:"modified,omitempty"`
	Type        string          `json:"type"`
	Path        string          `json:"path"`
	TTL         int             `json:"ttl"`
	NotFoundTTL int             `json:"notFoundTtl"`
	Sort        int             `json:"sort,omitempty"`
	Enabled     bool            `json:"enabled"`
	Enforce     bool            `json:"enforce"`
}

CacheSetting ...

type Certificate added in v1.7.0

type Certificate struct {
	ID           int             `json:"id,omitempty"`
	Created      *types.DateTime `json:"created,omitempty"`
	Modified     *types.DateTime `json:"modified,omitempty"`
	Subject      string          `json:"subject"`
	Algorithm    string          `json:"algorithm"`
	ValidFrom    *types.DateTime `json:"validFrom"`
	ValidTo      *types.DateTime `json:"validTo"`
	Fingerprint  string          `json:"fingerprint"`
	SerialNumber string          `json:"serialNumber"`
	Cert         string          `json:"cert,omitempty"`
}

type DNSRecord

type DNSRecord struct {
	ID               int              `json:"id,omitempty"`
	Created          *types.DateTime  `json:"created,omitempty"`
	Modified         *types.DateTime  `json:"modified,omitempty"`
	Name             string           `json:"name"`
	Value            string           `json:"value"`
	RecordType       string           `json:"recordType"`
	AlternativeCNAME string           `json:"alternativeCname,omitempty"`
	Comment          string           `json:"comment,omitempty"`
	Active           bool             `json:"active"`
	Enabled          bool             `json:"enabled"`
	TTL              int              `json:"ttl"`
	Priority         int              `json:"priority,omitempty"`
	Port             int              `json:"port,omitempty"`
	UpstreamOptions  *UpstreamOptions `json:"upstreamOptions,omitempty"`
}

DNSRecord ...

type Domain

type Domain struct {
	ID          int             `json:"id,omitempty"`
	Created     *types.DateTime `json:"created,omitempty"`
	Modified    *types.DateTime `json:"modified,omitempty"`
	Name        string          `json:"name"`
	AutoUpdate  bool            `json:"autoUpdate"`
	AutoDNS     bool            `json:"autoDns"`
	Paused      bool            `json:"paused"`
	PausedUntil *types.DateTime `json:"pausedUntil,omitempty"`
}

Domain ...

type IPFilter

type IPFilter struct {
	ID         int             `json:"id,omitempty"`
	Created    *types.DateTime `json:"created,omitempty"`
	Modified   *types.DateTime `json:"modified,omitempty"`
	ExpireDate *types.DateTime `json:"expireDate,omitempty"`
	Value      string          `json:"value"`
	Type       string          `json:"type"`
	Comment    string          `json:"comment,omitempty"`
	Enabled    bool            `json:"enabled"`
}

IPFilter ...

type IPRange added in v1.5.0

type IPRange struct {
	ID        int             `json:"id,omitempty"`
	Created   *types.DateTime `json:"created,omitempty"`
	Modified  *types.DateTime `json:"modified,omitempty"`
	ValidFrom *types.DateTime `json:"validFrom,omitempty"`
	ValidTo   *types.DateTime `json:"validTo,omitempty"`
	Network   string          `json:"network"`
	Comment   string          `json:"comment,omitempty"`
	Enabled   bool            `json:"enabled"`
}

IPRange ...

type RateLimit

type RateLimit struct {
	ID            int             `json:"id,omitempty"`
	Created       *types.DateTime `json:"created,omitempty"`
	Modified      *types.DateTime `json:"modified,omitempty"`
	Burst         int             `json:"burst"`
	Network       string          `json:"network"`
	SubDomainName string          `json:"subDomainName"`
	Timeframe     int             `json:"timeframe"`
	Type          string          `json:"type"`
	Value         int             `json:"value"`
}

RateLimit ...

type Redirect

type Redirect struct {
	ID            int             `json:"id,omitempty"`
	Created       *types.DateTime `json:"created,omitempty"`
	Modified      *types.DateTime `json:"modified,omitempty"`
	Type          string          `json:"type"`
	SubDomainName string          `json:"subDomainName"`
	Source        string          `json:"source"`
	Destination   string          `json:"destination"`
	Comment       string          `json:"comment,omitempty"`
	MatchingType  string          `json:"matchingType"`
	Sort          int             `json:"sort,omitempty"`
	Enabled       bool            `json:"enabled"`
	ExpertMode    bool            `json:"expertMode"`
}

Redirect ...

type Response

type Response struct {
	Error         bool          `json:"error,omitempty"`
	ViolationList []*Violation  `json:"violationList,omitempty"`
	TargetObject  []interface{} `json:"targetObject,omitempty"`
	List          []interface{} `json:"list,omitempty"`
	Page          int           `json:"page,omitempty"`
	Count         int           `json:"count,omitempty"`
	PageSize      int           `json:"pageSize,omitempty"`
}

Response defines a response, returned by the MYRA API

type SSLCertificate added in v1.7.0

type SSLCertificate struct {
	*Certificate
	SubjectAlternatives []string          `json:"subjectAlternatives"`
	Intermediates       []SSLIntermediate `json:"intermediates,omitempty"`
	Wildcard            bool              `json:"wildcard"`
	ExtendedValidation  bool              `json:"extendedValidation"`
	Subdomains          []string          `json:"subdomains,omitempty"`
	Key                 string            `json:"key,omitempty"`
	CertRefreshForced   bool              `json:"certRefreshForced,omitempty"`
	CertToRefresh       int               `json:"certToRefresh,omitempty"`
}

type SSLIntermediate added in v1.7.0

type SSLIntermediate struct {
	*Certificate
	Issuer string `json:"issuer"`
}

type Settings

type Settings struct {
	AccessLog                   bool     `json:"access_log"`
	AntibotPostFlood            bool     `json:"antibot_post_flood"`
	AntibotPostFloodThreshold   int      `json:"antibot_post_flood_threshold,omitempty"`
	AntibotProofOfWork          bool     `json:"antibot_proof_of_work"`
	AntibotProofOfWorkThreshold int      `json:"antibot_proof_of_work_threshold,omitempty"`
	BalancingMethod             string   `json:"balancing_method,omitempty"`
	BlockNotWhitelisted         bool     `json:"block_not_whitelisted"`
	BlockTorNetwork             bool     `json:"block_tor_network"`
	CacheEnabled                bool     `json:"cache_enabled"`
	CacheRevalidate             bool     `json:"cache_revalidate"`
	CDN                         bool     `json:"cdn"`
	ClientMaxBodySize           int      `json:"client_max_body_size,omitempty"`
	DiffieHellmanExchange       int      `json:"diffie_hellman_exchange,omitempty"`
	EnableOriginSNI             bool     `json:"enable_origin_sni"`
	ForwardedForReplacement     string   `json:"forwarded_for_replacement,omitempty"`
	HSTS                        bool     `json:"hsts"`
	HSTSIncludeSubdomains       bool     `json:"hsts_include_subdomains"`
	HSTSMaxAge                  int      `json:"hsts_max_age,omitempty"`
	HSTSPreload                 bool     `json:"hsts_preload"`
	HTTPOriginPort              int      `json:"http_origin_port,omitempty"`
	IgnoreNoCache               bool     `json:"ignore_nocache"`
	ImageOptimization           bool     `json:"image_optimization"`
	IPv6Active                  bool     `json:"ipv6_active"`
	LimitAllowedHTTPMethod      []string `json:"limit_allowed_http_method,omitempty"`
	LimitTLSVersion             []string `json:"limit_tls_version,omitempty"`
	LogFormat                   string   `json:"log_format,omitempty"`
	MonitoringAlertThreshold    int      `json:"monitoring_alert_threshold,omitempty"`
	MonitoringContactEMail      string   `json:"monitoring_contact_email,omitempty"`
	MonitoringSendAlert         bool     `json:"monitoring_send_alert"`
	MyraSSLHeader               bool     `json:"myra_ssl_header"`
	NextUpstream                []string `json:"next_upstream,omitempty"`
	OnlyHTTPS                   bool     `json:"only_https"`
	OriginConnectionHeader      string   `json:"origin_connection_header,omitempty"`
	ProxyCacheBypass            string   `json:"proxy_cache_bypass,omitempty"`
	ProxyCacheStale             []string `json:"proxy_cache_stale,omitempty"`
	ProxyConnectTimeout         int      `json:"proxy_connect_timeout,omitempty"`
	ProxyReadTimeout            int      `json:"proxy_read_timeout,omitempty"`
	RequestLimitBlock           string   `json:"request_limit_block,omitempty"`
	RequestLimitLevel           int      `json:"request_limit_level,omitempty"`
	RequestLimitReport          bool     `json:"request_limit_report"`
	RequestLimitReportEMail     string   `json:"request_limit_report_email,omitempty"`
	Rewrite                     bool     `json:"rewrite"`
	SourceProtocol              string   `json:"source_protocol,omitempty"`
	Spdy                        bool     `json:"spdy"`
	SSLOriginPort               int      `json:"ssl_origin_port,omitempty"`
	WAFEnable                   bool     `json:"waf_enable"`
	WAFLevelsEnable             []string `json:"waf_levels_enable,omitempty"`
	WAFPolicy                   string   `json:"waf_policy,omitempty"`
}

Settings ...

type UpstreamOptions

type UpstreamOptions struct {
	ID          int             `json:"id,omitempty"`
	Created     *types.DateTime `json:"created,omitempty"`
	Modified    *types.DateTime `json:"modified,omitempty"`
	Backup      bool            `json:"backup"`
	Down        bool            `json:"down"`
	FailTimeout int             `json:"failTimeout"`
	MaxFails    int             `json:"maxFails"`
	Weight      int             `json:"weight"`
}

UpstreamOptions ...

type Violation

type Violation struct {
	Path    string `json:"path,omitempty"`
	Message string `json:"message,omitempty"`
}

Violation defines a violation VO, returned by the MYRA API

type WAFAction added in v1.3.0

type WAFAction struct {
	ID                int             `json:"id,omitempty"`
	Created           *types.DateTime `json:"created,omitempty"`
	Modified          *types.DateTime `json:"modified,omitempty"`
	ForceCustomValues bool            `json:"forceCustomValues"`
	AvailablePhases   int             `json:"availablePhases"`
	Name              string          `json:"name"`
	Type              string          `json:"type"`
	CustomKey         string          `json:"customKey"`
	Value             string          `json:"value"`
}

WAFAction ...

type WAFCondition added in v1.3.0

type WAFCondition struct {
	ID                int             `json:"id,omitempty"`
	Created           *types.DateTime `json:"created,omitempty"`
	Modified          *types.DateTime `json:"modified,omitempty"`
	ForceCustomValues bool            `json:"forceCustomValues"`
	AvailablePhases   int             `json:"availablePhases"`
	Alias             string          `json:"alias"`
	Category          string          `json:"category"`
	MatchingType      string          `json:"matchingType"`
	Name              string          `json:"name"`
	Key               string          `json:"key"`
	Value             string          `json:"value"`
}

WAFCondition ...

type WAFRule added in v1.3.0

type WAFRule struct {
	ID            int             `json:"id,omitempty"`
	Created       *types.DateTime `json:"created,omitempty"`
	Modified      *types.DateTime `json:"modified,omitempty"`
	ExpireDate    *types.DateTime `json:"expireDate,omitempty"`
	Name          string          `json:"name"`
	Description   string          `json:"description"`
	Direction     string          `json:"direction"`
	LogIdentifier string          `json:"logIdentifier"`
	RuleType      string          `json:"ruleType"`
	SubDomainName string          `json:"subDomainName"`
	Sort          int             `json:"sort"`
	Sync          bool            `json:"sync"`
	Template      bool            `json:"template"`
	ProcessNext   bool            `json:"processNext"`
	Enabled       bool            `json:"enabled"`
	Actions       []*WAFAction    `json:"actions"`
	Conditions    []*WAFCondition `json:"conditions"`
}

WAFRule ...

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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