ns1.NS1¶
This top level object is used to initialize and coordinate access to the NS1 platform. With it, you create objects for accessing either the basic REST interface, or the high level objects such as Zone and Record.
-
class
ns1.
NS1
(apiKey=None, config=None, configFile=None, keyID=None)¶ Create a new top level NS1 API object
Parameters: - apiKey (str) – if given, initialize config with this API key (obtainable via creation in NS1 portal)
- config (ns1.config.Config) – if given, uses a separately constructed and configured Config object
- configFile (str) – if given, load configuration from the given json configuration file
- keyID (str) – if given, use the specified key config in the multi-key configuration file
-
acls
()¶ Return a new raw REST interface to ACL resources
Return type: ns1.rest.acls.Acls
-
addresses
()¶ Return a new raw REST interface to address resources
Return type: ns1.rest.ipam.Adresses
-
apikey
()¶ Return a new raw REST interface to API key resources
Return type: ns1.rest.apikey.APIKey
-
client_classes
()¶ Return a new raw REST interface to Client Classes resources
Return type: ns1.rest.client_classes.ClientClasses
-
createAddress
(prefix, status, network_id, callback=None, errback=None, **kwargs)¶ Create a new Address For the list of keywords available, see
ns1.rest.ipam.Addresses.INT_FIELDS
andns1.rest.ipam.Addresses.PASSTHRU_FIELDS
Parameters:
-
createMonitor
(callback=None, errback=None, **kwargs)¶ Create a monitor
-
createNetwork
(name, scope_group_id=None, callback=None, errback=None, **kwargs)¶ Create a new Network For the list of keywords available, see
ns1.rest.ipam.Networks.INT_FIELDS
andns1.rest.ipam.Networks.PASSTHRU_FIELDS
Parameters:
-
createReservation
(scopegroup_id, address_id, mac, dhcp_options=None, callback=None, errback=None, **kwargs)¶ Create a new Reservation For the list of keywords available, see
ns1.rest.ipam.Reservation.INT_FIELDS
andns1.rest.ipam.Reservation.PASSTHRU_FIELDS
Parameters:
-
createScope
(scopegroup_id, address_id, dhcp_options=None, callback=None, errback=None, **kwargs)¶ Create a new Scope For the list of keywords available, see
ns1.rest.ipam.Scope.INT_FIELDS
andns1.rest.ipam.Scope.PASSTHRU_FIELDS
Parameters: - scopegroup_id (int) – id of the scope group
- address_id (int) – id of the address the scope is associated with
- options (DHCPOptions) – DHCPOptions object that contains the settings for the scope
-
createScopeGroup
(name, service_def_id, dhcp4, dhcp6, callback=None, errback=None, **kwargs)¶ Create a new Scope Group For the list of keywords available, see
ns1.rest.ipam.ScopeGroups.INT_FIELDS
andns1.rest.ipam.ScopeGroups.PASSTHRU_FIELDS
Parameters: - name (str) – Name of the Scope Group to be created
- service_group_id (int) – id of the service group the Scope group is associated with
- dhcp4 (ns1.ipam.DHCPIOptions) – DHCPOptions object that contains the options for dhcpv4
- dhcp6 (ns1.ipam.DHCPIOptions) – DHCPOptions object that contains the options for dhcpv6
-
createZone
(zone, zoneFile=None, callback=None, errback=None, **kwargs)¶ Create a new zone, and return an associated high level Zone object. Several optional keyword arguments are available to configure the SOA record.
If zoneFile is specified, upload the specific zone definition file to populate the zone with.
Parameters: Return type:
-
datafeed
()¶ Return a new raw REST interface to feed resources
Return type: ns1.rest.data.Feed
-
datasource
()¶ Return a new raw REST interface to datasource resources
Return type: ns1.rest.data.Source
-
dhcp_option_spaces
()¶ Return a new raw REST interface to DHCP Option Spaces resources
Return type: ns1.rest.dhcp_option_spaces.DHCOptionSpaces
-
generateDHCPOptionsTemplate
(address_family)¶ Generate boilerplate dictionary to hold dhcp options
Parameters: address_family (str) – dhcpv4 or dhcpv6 Returns: dict containing valid option set for address family
-
loadAddressbyID
(id, callback=None, errback=None)¶ Load an existing address by ID into a high level Address object
Parameters: id (int) – id of an existing Address
-
loadAddressbyPrefix
(prefix, status, network_id, callback=None, errback=None)¶ Load an existing address by prefix, status and network into a high level Address object
Parameters:
-
loadDHCPOptions
(address_family, options)¶ Create a high level DHCPOptions object
Parameters: - address_family (str) – Address family of the options. Can be either dhcpv4 or dhcpv6
- options (dict) – Dictionary containing the option set to apply for this address family. Note: only those specified will be applied. Allowed options can be found in
ns1.ipam.DHCPOptions.OPTIONS
-
loadLeases
(scope_group_id=None, scope_id=None, limit=None, offset=None, callback=None, errback=None)¶
-
loadMonitors
(callback=None, errback=None, **kwargs)¶ Load all monitors
-
loadNetworkbyID
(id, callback=None, errback=None)¶ Load an existing Network by ID into a high level Network object
Parameters: id (int) – id of an existing Network
-
loadNetworkbyName
(name, callback=None, errback=None)¶ Load an existing Network by name into a high level Network object
Parameters: name (str) – Name of an existing Network
-
loadRecord
(domain, type, zone=None, callback=None, errback=None, **kwargs)¶ Load an existing record into a high level Record object.
Parameters: - domain (str) – domain name of the record in the zone, for example ‘myrecord’. You may leave off the zone, if it is specified in the zone parameter. This is recommended. You can pass a fully qualified domain and not pass the zone argument, but this will not work as expected if there are any dots in the domain, e.g. foo.example.com is OK, foo.bar.example.com will not work as expected.
- type (str) – record type, such as ‘A’, ‘MX’, ‘AAAA’, etc.
- zone (str) – zone name, like ‘example.com’
Return type:
-
loadReservation
(scopegroup_id, address_id, reservation_id=None, callback=None, errback=None)¶
-
loadScope
(scopegroup_id, address_id, callback=None, errback=None)¶
-
loadScopeGroup
(id, callback=None, errback=None)¶ Load an existing Scope Group into a high level Scope Group object
Parameters: id (int) – id of an existing ScopeGroup
-
loadZone
(zone, callback=None, errback=None)¶ Load an existing zone into a high level Zone object.
Parameters: zone (str) – zone name, like ‘example.com’ Return type: ns1.zones.Zone
-
monitoring_jobtypes
()¶ Return a new raw REST interface to monitoring jobtypes resources
Return type: ns1.rest.monitoring.JobTypes
-
monitoring_regions
()¶ Return a new raw REST interface to monitoring regions resources
Return type: ns1.rest.monitoring.Regions
-
monitors
()¶ Return a new raw REST interface to monitors resources
Return type: ns1.rest.monitoring.Monitors
-
networks
()¶ Return a new raw REST interface to network resources
Return type: ns1.rest.ipam.Networks
-
notifylists
()¶ Return a new raw REST interface to notify list resources
Return type: ns1.rest.monitoring.NotifyLists
-
optiondefs
()¶ Return a new raw REST interface to optiondefs resources
Return type: ns1.rest.ipam.Optiondefs
-
plan
()¶ Return a new raw REST interface to account plan
Return type: ns1.rest.account.Plan
-
pools
()¶ Return a new raw REST interface to Pools resources
Return type: ns1.rest.pools.Pools
-
records
()¶ Return a new raw REST interface to record resources
Return type: ns1.rest.records.Records
-
reservations
()¶ Return a new raw REST interface to reservation resources
Return type: ns1.rest.ipam.Reservations
-
scope_groups
()¶ Return a new raw REST interface to scope_group resources
Return type: ns1.rest.ipam.Scopegroups
-
scopes
()¶ Return a new raw REST interface to scope resources
Return type: ns1.rest.ipam.Scopes
-
searchZone
(query, type='all', expand=True, max=None, callback=None, errback=None)¶ This method was updated since NS1 deprecated v1/search/zones Search a zone record or answers for a given search query (e.g., for geological data, etc)
Parameters: - query – query to search zone name or other type name
- type – String Filters search results by type. Enum: “zone”, “record”, “all”, “answers”
- expand – Boolean Expands contents of search results.
- max – Integer Maximum number of search results to display
Returns: list of zones searched
-
stats
()¶ Return a new raw REST interface to stats resources
Return type: ns1.rest.stats.Stats
-
team
()¶ Return a new raw REST interface to team resources
Return type: ns1.rest.team.Team
-
tsig
()¶ Return a new raw REST interface to tsgi resources
Return type: ns1.rest.tsig.Tsgi
-
user
()¶ Return a new raw REST interface to user resources
Return type: ns1.rest.user.User
-
views
()¶ Return a new raw REST interface to View resources
Return type: ns1.rest.views.Views
-
zones
()¶ Return a new raw REST interface to zone resources
Return type: ns1.rest.zones.Zones