本文整理汇总了Python中dyn.tm.session.DynectSession类的典型用法代码示例。如果您正苦于以下问题:Python DynectSession类的具体用法?Python DynectSession怎么用?Python DynectSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DynectSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
def delete(self, publish='Y'):
"""Delete this HTTPRedirect service from the DynECT System
publish='N' can be passed into this function to do a soft-delete which
will be acted upon during a zone publish.
"""
api_args = {'publish': publish}
DynectSession.get_session().execute(self.uri, 'DELETE', api_args)
示例2: delete
def delete(self):
"""Delete this :class:`RegionPoolEntry`"""
uri = '/RTTMRegionPoolEntry/{}/{}/{}/{}/'.format(self._zone,
self._fqdn,
self._region_code,
self._address)
DynectSession.get_session().execute(uri, 'DELETE', {})
示例3: protocol
def protocol(self, value):
if value not in self.valid_protocols:
raise Exception
self._protocol = value
api_args = {'monitor': {'protocol': self._protocol}}
uri = '/Failover/{}/{}/'.format(self.zone, self.fqdn)
DynectSession.get_session().execute(uri, 'PUT', api_args)
示例4: delete
def delete(self):
"""Delete this :class:`AdvancedRedirectRule` service
from the DynECT System
"""
self.uri = '/AdvRedirectRule/{}/{}/{}'.format(self._zone,
self._fqdn,
self._public_id)
DynectSession.get_session().execute(self.uri, 'DELETE', {})
示例5: _update
def _update(self, api_args):
"""Update the Dyn System with data from this
:class:`PerformanceMonitor`
"""
uri = '/RTTM/{}/{}/'.format(self.zone, self.fqdn)
response = DynectSession.get_session().execute(uri, 'PUT', api_args)
self._build(response['data']['performance_monitor'])
示例6: _update
def _update(self, api_args=None):
"""Update an existing :class:`AdvancedRedirect` Service
on the DynECT System"""
self.uri = '/AdvRedirect/{}/{}/'.format(self._zone, self._fqdn)
response = DynectSession.get_session().execute(self.uri, 'PUT',
api_args)
self._build(response['data'])
示例7: get_any_records
def get_any_records(self):
"""Retrieve a list of all :class:`DNSRecord`'s associated with this
:class:`Zone`
"""
if self.fqdn is None:
return
api_args = {'detail': 'Y'}
uri = '/ANYRecord/{}/{}/'.format(self._name, self.fqdn)
response = DynectSession.get_session().execute(uri, 'GET', api_args)
# Strip out empty record_type lists
record_lists = {label: rec_list for label, rec_list in
response['data'].items() if rec_list != []}
records = {}
for key, record_list in record_lists.items():
search = key.split('_')[0].upper()
try:
constructor = RECS[search]
except KeyError:
constructor = RECS['UNKNOWN']
list_records = []
for record in record_list:
del record['zone']
del record['fqdn']
# Unpack rdata
for r_key, r_val in record['rdata'].items():
record[r_key] = r_val
record['create'] = False
list_records.append(constructor(self._name, self.fqdn,
**record))
records[key] = list_records
return records
示例8: get_all_records
def get_all_records(self):
"""Retrieve a list of all record resources for the specified node and
zone combination as well as all records from any Base_Record below that
point on the zone hierarchy
"""
self.records = {}
uri = '/AllRecord/{}/'.format(self.zone)
if self.fqdn is not None:
uri += '{}/'.format(self.fqdn)
api_args = {'detail': 'Y'}
response = DynectSession.get_session().execute(uri, 'GET', api_args)
# Strip out empty record_type lists
record_lists = {label: rec_list for label, rec_list in
response['data'].items() if rec_list != []}
records = {}
for key, record_list in record_lists.items():
search = key.split('_')[0].upper()
try:
constructor = RECS[search]
except KeyError:
constructor = RECS['UNKNOWN']
list_records = []
for record in record_list:
del record['zone']
fqdn = record['fqdn']
del record['fqdn']
# Unpack rdata
for r_key, r_val in record['rdata'].items():
record[r_key] = r_val
record['create'] = False
list_records.append(constructor(self.zone, fqdn, **record))
records[key] = list_records
return records
示例9: _post
def _post(self, pool, serve_count=None, failover_mode=None,
failover_data=None):
"""Create a new :class:`GSLBRegion` on the DynECT System"""
self._pool = pool
self._serve_count = serve_count
self._failover_mode = failover_mode
self._failover_data = failover_data
uri = '/GSLBRegion/{}/{}/'.format(self._zone, self._fqdn)
api_args = {'pool': self._pool.to_json(),
'region_code': self._region_code}
if serve_count:
api_args['serve_count'] = self._serve_count
if self._failover_mode:
if self._failover_mode not in self.valid_modes:
raise DynectInvalidArgumentError('failover_mode',
self._failover_mode,
self.valid_modes)
api_args['failover_mode'] = self._failover_mode
if self._failover_data:
if self._failover_data not in self.valid_modes:
raise DynectInvalidArgumentError('failover_data',
self._failover_data,
self.valid_modes)
api_args['failover_data'] = self._failover_data
response = DynectSession.get_session().execute(uri, 'POST', api_args)
self._build(response['data'])
示例10: _post
def _post(self):
"""Create a new :class:`RTTMRegion` on the DynECT System"""
uri = '/RTTMRegion/{}/{}/'.format(self._zone, self._fqdn)
api_args = {'region_code': self._region_code,
'pool': [poole.to_json() for poole in self._pool]}
if self._autopopulate:
if self._autopopulate not in ('Y', 'N'):
raise DynectInvalidArgumentError('autopopulate',
self._autopopulate,
('Y', 'N'))
api_args['autopopulate'] = self._autopopulate
if self._ep:
api_args['ep'] = self._ep
if self._apmc:
api_args['apmc'] = self._apmc
if self._epmc:
api_args['epmc'] = self._epmc
if self._serve_count:
api_args['serve_count'] = self._serve_count
if self._failover_mode:
if self._failover_mode not in self.valid_modes:
raise DynectInvalidArgumentError('failover_mode',
self._failover_mode,
self.valid_modes)
api_args['failover_mode'] = self._failover_mode
if self._failover_data:
if self._failover_data not in self.valid_modes:
raise DynectInvalidArgumentError('failover_data',
self._failover_data,
self.valid_modes)
api_args['failover_data'] = self._failover_data
response = DynectSession.get_session().execute(uri, 'POST', api_args)
self._build(response['data'])
示例11: get_qps
def get_qps(self, start_ts, end_ts=None, breakdown=None, hosts=None,
rrecs=None):
"""Generates a report with information about Queries Per Second (QPS)
for this zone
:param start_ts: datetime.datetime instance identifying point in time
for the QPS report
:param end_ts: datetime.datetime instance indicating the end of the
data range for the report. Defaults to datetime.datetime.now()
:param breakdown: By default, most data is aggregated together.
Valid values ('hosts', 'rrecs', 'zones').
:param hosts: List of hosts to include in the report.
:param rrecs: List of record types to include in report.
:return: A :class:`str` with CSV data
"""
end_ts = end_ts or datetime.now()
api_args = {'start_ts': unix_date(start_ts),
'end_ts': unix_date(end_ts),
'zones': [self.name]}
if breakdown is not None:
api_args['breakdown'] = breakdown
if hosts is not None:
api_args['hosts'] = hosts
if rrecs is not None:
api_args['rrecs'] = rrecs
response = DynectSession.get_session().execute('/QPSReport/',
'POST', api_args)
return response['data']
示例12: _post
def _post(self, record_type, address, user=None):
"""Create a new DynamicDNS Service on the DynECT System"""
self._record_type = record_type
self._address = address
if user:
self._user = user
self.uri = '/DDNS/{}/{}/{}/'.format(self._zone, self._fqdn,
self._record_type)
api_args = {'address': self._address}
if user:
api_args['user'] = self._user
api_args['full_setup'] = True
response = DynectSession.get_session().execute(self.uri, 'POST',
api_args)
for key, val in response['data'].items():
if user:
if key == 'ddns':
for ddns_key, ddns_val in val.items():
setattr(self, '_' + ddns_key, ddns_val)
if key == 'new_user':
user_name = val['user_name']
del val['user_name']
self._user = User(user_name, api=False, **val)
elif key == 'active':
self._active = Active(val)
else:
setattr(self, '_' + key, val)
示例13: deactivate
def deactivate(self):
"""Deactivate this Dynamic DNS service"""
api_args = {'deactivate': True}
response = DynectSession.get_session().execute(self.uri, 'PUT',
api_args)
for key, val in response['data'].items():
setattr(self, '_' + key, val)
示例14: reset
def reset(self):
"""Resets the abuse count on this Dynamic DNS service"""
api_args = {'reset': True}
response = DynectSession.get_session().execute(self.uri, 'PUT',
api_args)
for key, val in response['data'].items():
setattr(self, '_' + key, val)
示例15: _update
def _update(self, api_args):
"""Update this object by making a PUT API call with the provided
api_args
"""
response = DynectSession.get_session().execute(self.uri, 'PUT',
api_args)
self._build(response['data'])