text
stringlengths
0
828
self.playTone(t[""freq""], t[""reps""], t[""delay""], t[""muteDelay""])
self.stopTone()
return True"
3960,"def all(self, instance):
""""""Get all ACLs associated with the instance specified by name.
:param str instance: The name of the instance from which to fetch ACLs.
:returns: A list of :py:class:`Acl` objects associated with the specified instance.
:rtype: list
""""""
url = self._url.format(instance=instance)
response = requests.get(url, **self._default_request_kwargs)
data = self._get_response_data(response)
return self._concrete_acl_list(data)"
3961,"def create(self, instance, cidr_mask, description, **kwargs):
""""""Create an ACL entry for the specified instance.
:param str instance: The name of the instance to associate the new ACL entry with.
:param str cidr_mask: The IPv4 CIDR mask for the new ACL entry.
:param str description: A short description for the new ACL entry.
:param collector kwargs: (optional) Additional key=value pairs to be supplied to the
creation payload. **Caution:** fields unrecognized by the API will cause this request
to fail with a 400 from the API.
""""""
# Build up request data.
url = self._url.format(instance=instance)
request_data = {
'cidr_mask': cidr_mask,
'description': description
}
request_data.update(kwargs)
# Call to create an instance.
response = requests.post(
url,
data=json.dumps(request_data),
**self._default_request_kwargs
)
# Log outcome of instance creation request.
if response.status_code == 200:
logger.info('Successfully created a new ACL for instance {} with: {}.'
.format(instance, request_data))
else:
logger.info('Failed to create a new ACL for instance {} with: {}.'
.format(instance, request_data))
data = self._get_response_data(response)
return self._concrete_acl(data)"
3962,"def get(self, instance, acl):
""""""Get an ACL by ID belonging to the instance specified by name.
:param str instance: The name of the instance from which to fetch the ACL.
:param str acl: The ID of the ACL to fetch.
:returns: An :py:class:`Acl` object, or None if ACL does not exist.
:rtype: :py:class:`Acl`
""""""
base_url = self._url.format(instance=instance)
url = '{base}{aclid}/'.format(base=base_url, aclid=acl)
response = requests.get(url, **self._default_request_kwargs)
data = self._get_response_data(response)
return self._concrete_acl(data)"
3963,"def delete(self, instance, acl):
""""""Delete an ACL by ID belonging to the instance specified by name.
:param str instance: The name of the instance on which the ACL exists.
:param str acll: The ID of the ACL to delete.
""""""
base_url = self._url.format(instance=instance)
url = '{base}{aclid}/'.format(base=base_url, aclid=acl)
response = requests.delete(url, **self._default_request_kwargs)
if response.status_code == 200:
logger.info('Successfully deleted ACL {}'.format(acl))
else:
logger.info('Failed to delete ACL {}'.format(acl))
logger.info('Response: [{0}] {1}'.format(response.status_code, response.content))
raise errors.ObjectRocketException('Failed to delete ACL.')"
3964,"def _concrete_acl(self, acl_doc):
""""""Concretize an ACL document.
:param dict acl_doc: A document describing an ACL entry. Should come from the API.
:returns: An :py:class:`Acl`, or None.
:rtype: :py:class:`bases.BaseInstance`
""""""
if not isinstance(acl_doc, dict):
return None
# Attempt to instantiate an Acl object with the given dict.
try:
return Acl(document=acl_doc, acls=self)
# If construction fails, log the exception and return None.
except Exception as ex:
logger.exception(ex)
logger.error('Could not instantiate ACL document. You probably need to upgrade to a '
'recent version of the client. Document which caused this error: {}'
.format(acl_doc))
return None"