import "gopkg.in/ns1/ns1-go.v2/rest"
Package rest defines the api services used to communicate with NS1.
account_apikey.go account_setting.go account_team.go account_user.go account_warning.go client.go data_feed.go data_source.go ddi.go dnssec.go doc.go headers.go ipam.go monitor_job.go monitor_notify.go optiondef.go record.go reservation.go scope.go scopegroup.go stat.go util.go zone.go
var ( // ErrKeyExists bundles PUT create error. ErrKeyExists = errors.New("key already exists") // ErrKeyMissing bundles GET/POST/DELETE error. ErrKeyMissing = errors.New("key does not exist") )
var ( // ErrTeamExists bundles PUT create error. ErrTeamExists = errors.New("team already exists") // ErrTeamMissing bundles GET/POST/DELETE error. ErrTeamMissing = errors.New("team does not exist") )
var ( // ErrUserExists bundles PUT create error. ErrUserExists = errors.New("user already exists") // ErrUserMissing bundles GET/POST/DELETE error. ErrUserMissing = errors.New("user does not exist") )
var ( // ErrListExists bundles PUT create error. ErrListExists = errors.New("notify List already exists") // ErrListMissing bundles GET/POST/DELETE error. ErrListMissing = errors.New("notify List does not exist") )
var ( // ErrRecordExists bundles PUT create error. ErrRecordExists = errors.New("record already exists") // ErrRecordMissing bundles GET/POST/DELETE error. ErrRecordMissing = errors.New("record does not exist") )
var ( // ErrZoneExists bundles PUT create error. ErrZoneExists = errors.New("zone already exists") // ErrZoneMissing bundles GET/POST/DELETE error. ErrZoneMissing = errors.New("zone does not exist") )
var ( // ErrDNSECNotEnabled if DNSSEC is not enabled for the zone, regardless of // account-level DNSSEC permission. ErrDNSECNotEnabled = errors.New("DNSSEC is not enabled on the zone") )
CheckResponse handles parsing of rest api errors. Returns nil if no error.
SetAPIKey sets a Client instances' APIKey.
SetBoolParam sets a url boolean query param given the parameters name.
SetDDIAPI configures the client to use permissions compatible with the DDI API.
SetEndpoint sets a Client instances' Endpoint.
SetFollowPagination sets a Client instances' FollowPagination attribute.
SetHTTPClient sets a Client instances' httpClient.
SetIntParam sets a url integer query param given the parameters name.
SetRateLimitFunc sets a Client instances' RateLimitFunc.
SetStringParam sets a url string query param given the parameters name.
SetTimeParam sets a url timestamp query param given the parameters name.
SetUserAgent sets a Client instances' user agent.
type APIKeysService service
APIKeysService handles 'account/apikeys' endpoint.
Create takes a *APIKey and creates a new account apikey.
NS1 API docs: https://ns1.com/api/#apikeys-put
Delete deletes an apikey.
NS1 API docs: https://ns1.com/api/#apikeys-id-delete
Get returns details of an api key, including permissions, for a single API Key. Note: do not use the API Key itself as the keyid in the URL — use the id of the key.
NS1 API docs: https://ns1.com/api/#apikeys-id-get
List returns all api keys in the account.
NS1 API docs: https://ns1.com/api/#apikeys-get
Update changes the name or access rights for an API Key.
NS1 API docs: https://ns1.com/api/#apikeys-id-post
type Client struct { // NS1 rest endpoint, overrides default if given. Endpoint *url.URL // NS1 api key (value for http request header 'X-NSONE-Key'). APIKey string // NS1 go rest user agent (value for http request header 'User-Agent'). UserAgent string // Func to call after response is returned in Do RateLimitFunc func(RateLimit) // Whether the client should handle paginated responses automatically. FollowPagination bool // Enables permissions compatibility with the DDI API. DDI bool // Services used for communicating with different components of the NS1 API. APIKeys *APIKeysService DataFeeds *DataFeedsService DataSources *DataSourcesService Jobs *JobsService Notifications *NotificationsService Records *RecordsService Settings *SettingsService Stats *StatsService Teams *TeamsService Users *UsersService Warnings *WarningsService Zones *ZonesService DNSSEC *DNSSECService IPAM *IPAMService ScopeGroup *ScopeGroupService Scope *ScopeService Reservation *ReservationService OptionDef *OptionDefService // contains filtered or unexported fields }
Client manages communication with the NS1 Rest API.
NewClient constructs and returns a reference to an instantiated Client.
Do satisfies the Doer interface. resp will be nil if a non-HTTP error occurs, otherwise it is available for inspection when the error reflects a non-2XX response.
func (c Client) DoWithPagination(req *http.Request, v interface{}, f NextFunc) (*http.Response, error)
DoWithPagination Does, and follows Link headers for pagination. The returned Response is from the last URI visited - either the last page, or one that responded with a non-2XX status. If a non-HTTP error occurs, resp will be nil.
NewRequest constructs and returns a http.Request.
RateLimitStrategyConcurrent sleeps for WaitTime * parallelism when remaining is less than or equal to parallelism.
RateLimitStrategySleep sets RateLimitFunc to sleep by WaitTimeRemaining
type DNSSECService service
DNSSECService handles 'zones/ZONE/dnssec' endpoint.
func (s *DNSSECService) Get(zone string) (*dns.ZoneDNSSEC, *http.Response, error)
Get takes a zone, and returns DNSSEC information.
NS1 API docs: https://ns1.com/api#get-get-dnssec-details-for-a-zone
type DataFeedsService service
DataFeedsService handles 'data/feeds' endpoint.
Create takes a *DataFeed and connects a new data feed to an existing data source.
NS1 API docs: https://ns1.com/api/#feeds-put
Delete takes a data source ID and a data feed ID and disconnects the feed from the data source and all attached destination metadata tables.
NS1 API docs: https://ns1.com/api/#feeds-delete
Get takes a data source ID and a data feed ID and returns the details of a single data feed
NS1 API docs: https://ns1.com/api/#feeds-feed-get
List returns all data feeds connected to a given data source.
NS1 API docs: https://ns1.com/api/#feeds-get
Update takes a *Feed and modifies and existing data feed. Note:
- The 'data' portion of a feed does not actually get updated during a POST. In order to update a feeds' 'data' attribute, one must use the Publish method. - Both the 'destinations' and 'networks' attributes are not updated during a POST.
NS1 API docs: https://ns1.com/api/#feeds-post
type DataSourcesService service
DataSourcesService handles 'data/sources' endpoint.
Create takes a *DataSource and creates a new data source.
NS1 API docs: https://ns1.com/api/#sources-put
Delete takes an ID and removes an existing data source and all connected feeds from the source.
NS1 API docs: https://ns1.com/api/#sources-delete
Get takes an ID returns the details for a single data source.
NS1 API docs: https://ns1.com/api/#sources-source-get
List returns all connected data sources.
NS1 API docs: https://ns1.com/api/#sources-get
Publish takes a datasources' id and data to publish.
NS1 API docs: https://ns1.com/api/#feed-post
Update takes a *DataSource modifies basic details of a data source. NOTE: This does not 'publish' data. See the Publish method.
NS1 API docs: https://ns1.com/api/#sources-post
A Decorator wraps a Doer with extra behavior, and doesnt affect the behavior of other instances of the same type.
Logging returns a Decorator that logs a Doer's requests. Dependency injection for the logger instance(inside the closures environment).
Doer is a single method interface that allows a user to extend/augment an http.Client instance. Note: http.Client satisfies the Doer interface.
Decorate decorates a Doer c with all the given Decorators, in order. Core object(Doer instance) that we want to apply layers(Decorator slice) to.
DoerFunc satisfies Interface. DoerFuncs are useful for adding logging/instrumentation to the http.Client that is used within the rest.APIClient.
Do is implementation of rest.Doer interface. Calls itself on the given http.Request.
Error contains all http responses outside the 2xx range.
Satisfy std lib error interface.
type IPAMService service
IPAMService handles the 'ipam' endpoint.
CreateSubnet creates an address or subnet. The Prefix and Network fields are required.
NS1 API docs: https://ns1.com/api#putcreate-a-subnet
DeleteSubnet removes a subnet entirely.
NS1 API docs: https://ns1.com/api#deletedelete-a-subnet
func (s *IPAMService) EditSubnet(addr *ipam.Address, parent bool) (newAddr, parentAddr *ipam.Address, resp *http.Response, err error)
EditSubnet updates an existing subnet. The ID field is required. Parent is whether or not to include the parent in the parent field.
NS1 API docs: https://ns1.com/api#postedit-a-subnet
GetChildren requests a list of all child addresses (or subnets) for the specified IP address.
NS1 API docs: https://ns1.com/api#getview-address-children
GetParent fetches the addresses parent.
NS1 API docs: https://ns1.com/api#getview-address-parent
GetSubnet returns the subnet corresponding to the provided address ID.
NS1 API docs: https://ns1.com/api#getview-a-subnet
ListAddrs returns a list of all root addresses (i.e. Parent == 0) in all networks.
NS1 API docs: https://ns1.com/api#getview-a-list-of-root-addresses
MergeSubnet merges several subnets together.
NS1 API docs: https://ns1.com/api#postmerge-a-subnet
func (s *IPAMService) SplitSubnet(id, prefix int) (rootAddr int, prefixIDs []int, resp *http.Response, err error)
SplitSubnet splits a block of unassigned IP space into equal pieces. This will not function with ranges or individual hosts. Normal breaking out of a subnet is done with the standard PUT route. (Eg. root address is a /24 and request for /29s will break it into 32 /29s)
- Only planned subnets can be split - Name and description will be unset on children - KVPS and options will be copied; tags will be inherited
NS1 API docs: https://ns1.com/api#postsplit-a-subnet
type JobsService service
JobsService handles 'monitoring/jobs' endpoint.
Create takes a *MonitoringJob and creates a new monitoring job.
NS1 API docs: https://ns1.com/api/#jobs-put
Delete takes an ID and immediately terminates and deletes and existing monitoring job.
NS1 API docs: https://ns1.com/api/#jobs-jobid-delete
Get takes an ID and returns details for a specific monitoring job.
NS1 API docs: https://ns1.com/api/#jobs-jobid-get
func (s *JobsService) History(id string, opts ...func(*url.Values)) ([]*monitor.StatusLog, *http.Response, error)
History takes an ID and returns status log history for a specific monitoring job.
NS1 API docs: https://ns1.com/api/#history-get
List returns all monitoring jobs for the account.
NS1 API docs: https://ns1.com/api/#jobs-get
Update takes a *MonitoringJob and change the configuration details of an existing monitoring job.
NS1 API docs: https://ns1.com/api/#jobs-jobid-post
Link has a URI and its relation (next/prev/last/etc)
Links represents a Link Header, keyed by the Rel attribute
ParseLink parses a Link header value into a Links, mainly cribbed from: https://github.com/peterhellberg/link/blob/master/link.go The forceHTTPS parameter will rewrite any HTTP URLs it finds to HTTPS.
Next gets the URI for "next", if present
NextFunc knows how to get and parse additional info from uri into v.
type NotificationsService service
NotificationsService handles 'monitoring/lists' endpoint.
func (s *NotificationsService) Create(nl *monitor.NotifyList) (*http.Response, error)
Create takes a *NotifyList and creates a new notify list.
NS1 API docs: https://ns1.com/api/#lists-put
Delete immediately deletes an existing notification list.
NS1 API docs: https://ns1.com/api/#lists-listid-delete
func (s *NotificationsService) Get(listID string) (*monitor.NotifyList, *http.Response, error)
Get returns the details and notifiers associated with a specific notification list.
NS1 API docs: https://ns1.com/api/#lists-listid-get
func (s *NotificationsService) List() ([]*monitor.NotifyList, *http.Response, error)
List returns all configured notification lists.
NS1 API docs: https://ns1.com/api/#lists-get
func (s *NotificationsService) Update(nl *monitor.NotifyList) (*http.Response, error)
Update adds or removes entries or otherwise update a notification list.
NS1 API docs: https://ns1.com/api/#list-listid-post
type OptionDefService service
OptionDefService handles the 'scope group' endpoints.
func (s *OptionDefService) Create(od *dhcp.OptionDef, odSpace, odKey string) (*dhcp.OptionDef, *http.Response, error)
Create creates or updates an option definition. The FriendlyName, Description, Code, Schema.Type fields are required.
NS1 API docs: https://ns1.com/api#putcreate-an-custom-dhcp-option-definition
Delete removes a option definition entirely.
NS1 API docs: https://ns1.com/api#deletedelete-a-custom-dhcp-option-definition
Get returns the option definition corresponding to the provided ID.
NS1 API docs: https://ns1.com/api#getview-dhcp-option-definition
List returns a list of all option definitions.
NS1 API docs: https://ns1.com/api#getlist-dhcp-option-definitions
RateLimit stores X-Ratelimit-* headers
PercentageLeft returns the ratio of Remaining to Limit as a percentage
WaitTime returns the time.Duration ratio of Period to Limit
WaitTimeRemaining returns the time.Duration ratio of Period to Remaining
RateLimitFunc is rate limiting strategy for the Client instance.
type RecordsService service
RecordsService handles 'zones/ZONE/DOMAIN/TYPE' endpoint.
Create takes a *Record and creates a new DNS record in the specified zone, for the specified domain, of the given record type.
The given record must have at least one answer. NS1 API docs: https://ns1.com/api/#record-put
Delete takes a zone, domain and record type t and removes an existing record and all associated answers and configuration details.
NS1 API docs: https://ns1.com/api/#record-delete
Get takes a zone, domain and record type t and returns full configuration for a DNS record.
NS1 API docs: https://ns1.com/api/#record-get
Update takes a *Record and modifies configuration details for an existing DNS record.
Only the fields to be updated are required in the given record. NS1 API docs: https://ns1.com/api/#record-post
type ReservationService service
ReservationService handles the 'reservation' endpoints.
func (s *ReservationService) Create(sc *dhcp.Reservation) (*dhcp.Reservation, *http.Response, error)
Create creates a reservation. The Options field is required.
NS1 API docs: https://ns1.com/api#putcreate-a-reservation
Delete removes a reservation entirely.
NS1 API docs: https://ns1.com/api#deletedelete-a-reservation
func (s *ReservationService) Edit(sc *dhcp.Reservation) (*dhcp.Reservation, *http.Response, error)
Edit updates an existing reservation. The ID, Options fields are required.
NS1 API docs: https://ns1.com/api#postmodify-a-reservation
func (s *ReservationService) Get(scID int) (*dhcp.Reservation, *http.Response, error)
Get returns the reservation corresponding to the provided reservation ID.
NS1 API docs: https://ns1.com/api#getview-a-reservations-details
func (s *ReservationService) List() ([]dhcp.Reservation, *http.Response, error)
List returns a list of all reservations.
NS1 API docs: https://ns1.com/api#getlist-reservations
Response wraps stdlib http response.
type ScopeGroupService service
ScopeGroupService handles the 'scope group' endpoints.
func (s *ScopeGroupService) Create(sg *dhcp.ScopeGroup) (*dhcp.ScopeGroup, *http.Response, error)
Create creates a scope group. The Name field is required.
NS1 API docs: https://ns1.com/api#putcreate-a-scope-group
Delete removes a Scope Group entirely.
NS1 API docs: https://ns1.com/api#deleteremove-scope-group-by-id
func (s *ScopeGroupService) Edit(sg *dhcp.ScopeGroup) (*dhcp.ScopeGroup, *http.Response, error)
Edit updates an existing scope group. The ID field is required.
NS1 API docs: https://ns1.com/api#postedit-scope-group
func (s *ScopeGroupService) Get(sgID int) (*dhcp.ScopeGroup, *http.Response, error)
Get returns the Scope Group corresponding to the provided scope group ID.
NS1 API docs: https://ns1.com/api#getview-scope-group
func (s *ScopeGroupService) List() ([]dhcp.ScopeGroup, *http.Response, error)
List returns a list of all scope groups.
NS1 API docs: https://ns1.com/api#getlist-scope-groups
type ScopeService service
ScopeService handles the 'scope' endpoints.
Create creates a scope. The IDAddress field is required.
NS1 API docs: https://ns1.com/api#putcreate-a-scope
Delete removes a scope entirely.
NS1 API docs: https://ns1.com/api#deleteremove-a-scope
Edit updates an existing scope. The IDAddress field is required.
NS1 API docs: https://ns1.com/api#postmodify-a-scope
Get returns the scope corresponding to the provided scope ID.
NS1 API docs: https://ns1.com/api#getview-scope-details
List returns a list of all scopes.
NS1 API docs: https://ns1.com/api#getlist-scopes
type SettingsService service
SettingsService handles 'account/settings' endpoint.
Get returns the basic contact details associated with the account.
NS1 API docs: https://ns1.com/api/#settings-get
Update changes most of the basic contact details, except customerid.
NS1 API docs: https://ns1.com/api/#settings-post
type StatsService service
StatsService handles 'stats/qps' endpoint.
GetQPS returns current queries per second (QPS) for the account. The QPS number is lagged by approximately 30 seconds for statistics collection; and the rate is computed over the preceding minute.
GetRecordQPS returns current queries per second (QPS) for a specific record. The QPS number is lagged by approximately 30 seconds for statistics collection; and the rate is computed over the preceding minute.
GetZoneQPS returns current queries per second (QPS) for a specific zone. The QPS number is lagged by approximately 30 seconds for statistics collection; and the rate is computed over the preceding minute.
type TeamsService service
TeamsService handles 'account/teams' endpoint.
Create takes a *Team and creates a new account team.
NS1 API docs: https://ns1.com/api/#teams-put
Delete deletes a team.
NS1 API docs: https://ns1.com/api/#teams-id-delete
Get returns details of a single team.
NS1 API docs: https://ns1.com/api/#teams-id-get
List returns all teams in the account.
NS1 API docs: https://ns1.com/api/#teams-get
Update changes the name or access rights for a team.
NS1 API docs: https://ns1.com/api/#teams-id-post
type UsersService service
UsersService handles 'account/users' endpoint.
Create takes a *User and creates a new account user.
NS1 API docs: https://ns1.com/api/#users-put
Delete deletes a user.
NS1 API docs: https://ns1.com/api/#users-user-delete
Get returns details of a single user.
NS1 API docs: https://ns1.com/api/#users-user-get
List returns all users in the account.
NS1 API docs: https://ns1.com/api/#users-get
Update change contact details, notification settings, or access rights for a user.
NS1 API docs: https://ns1.com/api/#users-user-post
type WarningsService service
WarningsService handles 'account/usagewarnings' endpoint.
func (s *WarningsService) Get() (*account.UsageWarning, *http.Response, error)
Get returns toggles and thresholds used when sending overage warning alert messages to users with billing notifications enabled.
NS1 API docs: https://ns1.com/api/#usagewarnings-get
func (s *WarningsService) Update(uw *account.UsageWarning) (*http.Response, error)
Update changes alerting toggles and thresholds for overage warning alert messages.
NS1 API docs: https://ns1.com/api/#usagewarnings-post
type ZonesService service
ZonesService handles 'zones' endpoint.
Create takes a *Zone and creates a new DNS zone.
NS1 API docs: https://ns1.com/api/#zones-put
Delete takes a zone and destroys an existing DNS zone and all records in the zone.
NS1 API docs: https://ns1.com/api/#zones-delete
Get takes a zone name and returns a single active zone and its basic configuration details.
NS1 API docs: https://ns1.com/api/#zones-zone-get
List returns all active zones and basic zone configuration details for each.
NS1 API docs: https://ns1.com/api/#zones-get
Update takes a *Zone and modifies basic details of a DNS zone.
NS1 API docs: https://ns1.com/api/#zones-post
Path | Synopsis |
---|---|
model | Package model defines structures for interacting with the NS1 API. |
model/account | Package account contains definitions for NS1 apikeys/teams/users/etc. |
model/data | Package data contains definitions for NS1 metadata/sources/feeds/etc. |
model/dhcp | Package dhcp contains definitions for scope groups, scopes, etc. |
model/dns | Package dns contains definitions for NS1 zones/records/answers/etc. |
model/filter | Package filter contains definitions for NS1 filter chains. |
model/ipam | Package ipam contains definitions for networks, addresses, etc. |
model/monitor | Package monitor contains definitions for NS1 monitoring jobs. |
Package rest imports 18 packages (graph) and is imported by 36 packages. Updated 2021-01-08. Refresh now. Tools for package owners.