desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Update an existing record in this Zone. Returns a Status object. :type old_record: ResourceRecord :param old_record: A ResourceRecord (e.g. returned by find_records) See _new_record for additional parameter documentation.'
def update_record(self, old_record, new_value, new_ttl=None, new_identifier=None, comment=''):
new_ttl = (new_ttl or default_ttl) record = copy.copy(old_record) changes = ResourceRecordSets(self.route53connection, self.id, comment) changes.add_change_record('DELETE', record) self._new_record(changes, record.type, record.name, new_value, new_ttl, new_identifier, comment) return Status(self...
'Delete one or more records from this Zone. Returns a Status object. :param record: A ResourceRecord (e.g. returned by find_records) or list, tuple, or set of ResourceRecords. :type comment: str :param comment: A comment that will be stored with the change.'
def delete_record(self, record, comment=''):
changes = ResourceRecordSets(self.route53connection, self.id, comment) if (type(record) in [list, tuple, set]): for r in record: changes.add_change_record('DELETE', r) else: changes.add_change_record('DELETE', record) return Status(self.route53connection, self._commit(changes...
'Add a new CNAME record to this Zone. See _new_record for parameter documentation. Returns a Status object.'
def add_cname(self, name, value, ttl=None, identifier=None, comment=''):
ttl = (ttl or default_ttl) name = self.route53connection._make_qualified(name) value = self.route53connection._make_qualified(value) return self.add_record(resource_type='CNAME', name=name, value=value, ttl=ttl, identifier=identifier, comment=comment)
'Add a new A record to this Zone. See _new_record for parameter documentation. Returns a Status object.'
def add_a(self, name, value, ttl=None, identifier=None, comment=''):
ttl = (ttl or default_ttl) name = self.route53connection._make_qualified(name) return self.add_record(resource_type='A', name=name, value=value, ttl=ttl, identifier=identifier, comment=comment)
'Add a new MX record to this Zone. See _new_record for parameter documentation. Returns a Status object.'
def add_mx(self, name, records, ttl=None, identifier=None, comment=''):
ttl = (ttl or default_ttl) records = self.route53connection._make_qualified(records) return self.add_record(resource_type='MX', name=name, value=records, ttl=ttl, identifier=identifier, comment=comment)
'Search this Zone for records that match given parameters. Returns None if no results, a ResourceRecord if one result, or a ResourceRecordSets if more than one result. :type name: str :param name: The name of the records should match this parameter :type type: str :param type: The type of the records should match this ...
def find_records(self, name, type, desired=1, all=False, identifier=None):
name = self.route53connection._make_qualified(name) returned = self.route53connection.get_all_rrsets(self.id, name=name, type=type) results = [] for r in returned: if ((r.name == name) and (r.type == type)): results.append(r) else: break weight = None regi...
'Search this Zone for CNAME records that match name. Returns a ResourceRecord. If there is more than one match return all as a ResourceRecordSets if all is True, otherwise throws TooManyRecordsException.'
def get_cname(self, name, all=False):
return self.find_records(name, 'CNAME', all=all)
'Search this Zone for A records that match name. Returns a ResourceRecord. If there is more than one match return all as a ResourceRecordSets if all is True, otherwise throws TooManyRecordsException.'
def get_a(self, name, all=False):
return self.find_records(name, 'A', all=all)
'Search this Zone for MX records that match name. Returns a ResourceRecord. If there is more than one match return all as a ResourceRecordSets if all is True, otherwise throws TooManyRecordsException.'
def get_mx(self, name, all=False):
return self.find_records(name, 'MX', all=all)
'Update the given CNAME record in this Zone to a new value, ttl, and identifier. Returns a Status object. Will throw TooManyRecordsException is name, value does not match a single record.'
def update_cname(self, name, value, ttl=None, identifier=None, comment=''):
name = self.route53connection._make_qualified(name) value = self.route53connection._make_qualified(value) old_record = self.get_cname(name) ttl = (ttl or old_record.ttl) return self.update_record(old_record, new_value=value, new_ttl=ttl, new_identifier=identifier, comment=comment)
'Update the given A record in this Zone to a new value, ttl, and identifier. Returns a Status object. Will throw TooManyRecordsException is name, value does not match a single record.'
def update_a(self, name, value, ttl=None, identifier=None, comment=''):
name = self.route53connection._make_qualified(name) old_record = self.get_a(name) ttl = (ttl or old_record.ttl) return self.update_record(old_record, new_value=value, new_ttl=ttl, new_identifier=identifier, comment=comment)
'Update the given MX record in this Zone to a new value, ttl, and identifier. Returns a Status object. Will throw TooManyRecordsException is name, value does not match a single record.'
def update_mx(self, name, value, ttl=None, identifier=None, comment=''):
name = self.route53connection._make_qualified(name) value = self.route53connection._make_qualified(value) old_record = self.get_mx(name) ttl = (ttl or old_record.ttl) return self.update_record(old_record, new_value=value, new_ttl=ttl, new_identifier=identifier, comment=comment)
'Delete a CNAME record matching name and identifier from this Zone. Returns a Status object. If there is more than one match delete all matching records if all is True, otherwise throws TooManyRecordsException.'
def delete_cname(self, name, identifier=None, all=False):
name = self.route53connection._make_qualified(name) record = self.find_records(name, 'CNAME', identifier=identifier, all=all) return self.delete_record(record)
'Delete an A record matching name and identifier from this Zone. Returns a Status object. If there is more than one match delete all matching records if all is True, otherwise throws TooManyRecordsException.'
def delete_a(self, name, identifier=None, all=False):
name = self.route53connection._make_qualified(name) record = self.find_records(name, 'A', identifier=identifier, all=all) return self.delete_record(record)
'Delete an MX record matching name and identifier from this Zone. Returns a Status object. If there is more than one match delete all matching records if all is True, otherwise throws TooManyRecordsException.'
def delete_mx(self, name, identifier=None, all=False):
name = self.route53connection._make_qualified(name) record = self.find_records(name, 'MX', identifier=identifier, all=all) return self.delete_record(record)
'Return a ResourceRecordsSets for all of the records in this zone.'
def get_records(self):
return self.route53connection.get_all_rrsets(self.id)
'Request that this zone be deleted by Amazon.'
def delete(self):
self.route53connection.delete_hosted_zone(self.id)
'Get the list of nameservers for this zone.'
def get_nameservers(self):
ns = self.find_records(self.name, 'NS') if (ns is not None): ns = ns.resource_records return ns
'This operation checks the availability of one domain name. You can access this API without authenticating. Note that if the availability status of a domain is pending, you must submit another request to determine the availability of the domain name. :type domain_name: string :param domain_name: The name of a domain. T...
def check_domain_availability(self, domain_name, idn_lang_code=None):
params = {'DomainName': domain_name} if (idn_lang_code is not None): params['IdnLangCode'] = idn_lang_code return self.make_request(action='CheckDomainAvailability', body=json.dumps(params))
'This operation removes the transfer lock on the domain (specifically the `clientTransferProhibited` status) to allow domain transfers. We recommend you refrain from performing this action unless you intend to transfer the domain to a different registrar. Successful submission returns an operation ID that you can use t...
def disable_domain_transfer_lock(self, domain_name):
params = {'DomainName': domain_name} return self.make_request(action='DisableDomainTransferLock', body=json.dumps(params))
'This operation sets the transfer lock on the domain (specifically the `clientTransferProhibited` status) to prevent domain transfers. Successful submission returns an operation ID that you can use to track the progress and completion of the action. If the request is not completed successfully, the domain registrant wi...
def enable_domain_transfer_lock(self, domain_name):
params = {'DomainName': domain_name} return self.make_request(action='EnableDomainTransferLock', body=json.dumps(params))
'This operation returns detailed information about the domain. The domain\'s contact information is also returned as part of the output. :type domain_name: string :param domain_name: The name of a domain. Type: String Default: None Constraints: The domain name can contain only the letters a through z, the numbers 0 thr...
def get_domain_detail(self, domain_name):
params = {'DomainName': domain_name} return self.make_request(action='GetDomainDetail', body=json.dumps(params))
'This operation returns the current status of an operation that is not completed. :type operation_id: string :param operation_id: The identifier for the operation for which you want to get the status. Amazon Route 53 returned the identifier in the response to the original request. Type: String Default: None Required: Y...
def get_operation_detail(self, operation_id):
params = {'OperationId': operation_id} return self.make_request(action='GetOperationDetail', body=json.dumps(params))
'This operation returns all the domain names registered with Amazon Route 53 for the current AWS account. :type marker: string :param marker: For an initial request for a list of domains, omit this element. If the number of domains that are associated with the current AWS account is greater than the value that you spec...
def list_domains(self, marker=None, max_items=None):
params = {} if (marker is not None): params['Marker'] = marker if (max_items is not None): params['MaxItems'] = max_items return self.make_request(action='ListDomains', body=json.dumps(params))
'This operation returns the operation IDs of operations that are not yet complete. :type marker: string :param marker: For an initial request for a list of operations, omit this element. If the number of operations that are not yet complete is greater than the value that you specified for `MaxItems`, you can use `Marke...
def list_operations(self, marker=None, max_items=None):
params = {} if (marker is not None): params['Marker'] = marker if (max_items is not None): params['MaxItems'] = max_items return self.make_request(action='ListOperations', body=json.dumps(params))
'This operation registers a domain. Domains are registered by the AWS registrar partner, Gandi. For some top-level domains (TLDs), this operation requires extra parameters. When you register a domain, Amazon Route 53 does the following: + Creates a Amazon Route 53 hosted zone that has the same name as the domain. Amazo...
def register_domain(self, domain_name, duration_in_years, admin_contact, registrant_contact, tech_contact, idn_lang_code=None, auto_renew=None, privacy_protect_admin_contact=None, privacy_protect_registrant_contact=None, privacy_protect_tech_contact=None):
params = {'DomainName': domain_name, 'DurationInYears': duration_in_years, 'AdminContact': admin_contact, 'RegistrantContact': registrant_contact, 'TechContact': tech_contact} if (idn_lang_code is not None): params['IdnLangCode'] = idn_lang_code if (auto_renew is not None): params['AutoRenew...
'This operation returns the AuthCode for the domain. To transfer a domain to another registrar, you provide this value to the new registrar. :type domain_name: string :param domain_name: The name of a domain. Type: String Default: None Constraints: The domain name can contain only the letters a through z, the numbers 0...
def retrieve_domain_auth_code(self, domain_name):
params = {'DomainName': domain_name} return self.make_request(action='RetrieveDomainAuthCode', body=json.dumps(params))
'This operation transfers a domain from another registrar to Amazon Route 53. Domains are registered by the AWS registrar, Gandi upon transfer. To transfer a domain, you need to meet all the domain transfer criteria, including the following: + You must supply nameservers to transfer a domain. + You must disable the dom...
def transfer_domain(self, domain_name, duration_in_years, nameservers, admin_contact, registrant_contact, tech_contact, idn_lang_code=None, auth_code=None, auto_renew=None, privacy_protect_admin_contact=None, privacy_protect_registrant_contact=None, privacy_protect_tech_contact=None):
params = {'DomainName': domain_name, 'DurationInYears': duration_in_years, 'Nameservers': nameservers, 'AdminContact': admin_contact, 'RegistrantContact': registrant_contact, 'TechContact': tech_contact} if (idn_lang_code is not None): params['IdnLangCode'] = idn_lang_code if (auth_code is not None)...
'This operation updates the contact information for a particular domain. Information for at least one contact (registrant, administrator, or technical) must be supplied for update. If the update is successful, this method returns an operation ID that you can use to track the progress and completion of the action. If th...
def update_domain_contact(self, domain_name, admin_contact=None, registrant_contact=None, tech_contact=None):
params = {'DomainName': domain_name} if (admin_contact is not None): params['AdminContact'] = admin_contact if (registrant_contact is not None): params['RegistrantContact'] = registrant_contact if (tech_contact is not None): params['TechContact'] = tech_contact return self.ma...
'This operation updates the specified domain contact\'s privacy setting. When the privacy option is enabled, personal information such as postal or email address is hidden from the results of a public WHOIS query. The privacy services are provided by the AWS registrar, Gandi. For more information, see the `Gandi privac...
def update_domain_contact_privacy(self, domain_name, admin_privacy=None, registrant_privacy=None, tech_privacy=None):
params = {'DomainName': domain_name} if (admin_privacy is not None): params['AdminPrivacy'] = admin_privacy if (registrant_privacy is not None): params['RegistrantPrivacy'] = registrant_privacy if (tech_privacy is not None): params['TechPrivacy'] = tech_privacy return self.ma...
'This operation replaces the current set of name servers for the domain with the specified set of name servers. If you use Amazon Route 53 as your DNS service, specify the four name servers in the delegation set for the hosted zone for the domain. If successful, this operation returns an operation ID that you can use t...
def update_domain_nameservers(self, domain_name, nameservers):
params = {'DomainName': domain_name, 'Nameservers': nameservers} return self.make_request(action='UpdateDomainNameservers', body=json.dumps(params))
'Add a change request to the set. :type action: str :param action: The action to perform (\'CREATE\'|\'DELETE\'|\'UPSERT\') :type name: str :param name: The name of the domain you want to perform the action on. :type type: str :param type: The DNS record type. Valid values are: * A * AAAA * CNAME * MX * NS * PTR * SOA...
def add_change(self, action, name, type, ttl=600, alias_hosted_zone_id=None, alias_dns_name=None, identifier=None, weight=None, region=None, alias_evaluate_target_health=None, health_check=None, failover=None):
change = Record(name, type, ttl, alias_hosted_zone_id=alias_hosted_zone_id, alias_dns_name=alias_dns_name, identifier=identifier, weight=weight, region=region, alias_evaluate_target_health=alias_evaluate_target_health, health_check=health_check, failover=failover) self.changes.append([action, change]) retur...
'Add an existing record to a change set with the specified action'
def add_change_record(self, action, change):
self.changes.append([action, change]) return
'Convert this ResourceRecordSet into XML to be saved via the ChangeResourceRecordSetsRequest'
def to_xml(self):
changesXML = '' for change in self.changes: changeParams = {'action': change[0], 'record': change[1].to_xml()} changesXML += (self.ChangeXML % changeParams) params = {'comment': self.comment, 'changes': changesXML} return (self.ChangeResourceRecordSetsBody % params)
'Commit this change'
def commit(self):
if (not self.connection): import boto self.connection = boto.connect_route53() return self.connection.change_rrsets(self.hosted_zone_id, self.to_xml())
'Overwritten to also add the NextRecordName, NextRecordType and NextRecordIdentifier to the base object'
def endElement(self, name, value, connection):
if (name == 'NextRecordName'): self.next_record_name = value elif (name == 'NextRecordType'): self.next_record_type = value elif (name == 'NextRecordIdentifier'): self.next_record_identifier = value else: return super(ResourceRecordSets, self).endElement(name, value, conn...
'Override the next function to support paging'
def __iter__(self):
results = super(ResourceRecordSets, self).__iter__() truncated = self.is_truncated while results: for obj in results: (yield obj) if self.is_truncated: self.is_truncated = False results = self.connection.get_all_rrsets(self.hosted_zone_id, name=self.next_r...
'Add a resource record value'
def add_value(self, value):
self.resource_records.append(value)
'Make this an alias resource record set'
def set_alias(self, alias_hosted_zone_id, alias_dns_name, alias_evaluate_target_health=False):
self.alias_hosted_zone_id = alias_hosted_zone_id self.alias_dns_name = alias_dns_name self.alias_evaluate_target_health = alias_evaluate_target_health
'Spit this resource record set out as XML'
def to_xml(self):
if ((self.alias_hosted_zone_id is not None) and (self.alias_dns_name is not None)): if (self.alias_evaluate_target_health is not None): eval_target_health = (self.EvaluateTargetHealth % ('true' if self.alias_evaluate_target_health else 'false')) else: eval_target_health = '' ...
'Uncallable constructor on abstract base StorageUri class.'
def __init__(self):
raise BotoClientError('Attempt to instantiate abstract StorageUri class')
'Returns string representation of URI.'
def __repr__(self):
return self.uri
'Returns true if two URIs are equal.'
def equals(self, uri):
return (self.uri == uri.uri)
'Opens a connection to appropriate provider, depending on provider portion of URI. Requires Credentials defined in boto config file (see boto/pyami/config.py). @type storage_uri: StorageUri @param storage_uri: StorageUri specifying a bucket or a bucket+object @rtype: L{AWSAuthConnection<boto.gs.connection.AWSAuthConnec...
def connect(self, access_key_id=None, secret_access_key=None, **kwargs):
connection_args = dict((self.connection_args or ())) if (hasattr(self, 'suppress_consec_slashes') and ('suppress_consec_slashes' not in connection_args)): connection_args['suppress_consec_slashes'] = self.suppress_consec_slashes connection_args.update(kwargs) if (not self.connection): if...
'Instantiate a BucketStorageUri from scheme,bucket,object tuple. @type scheme: string @param scheme: URI scheme naming the storage provider (gs, s3, etc.) @type bucket_name: string @param bucket_name: bucket name @type object_name: string @param object_name: object name, excluding generation/version. @type debug: int @...
def __init__(self, scheme, bucket_name=None, object_name=None, debug=0, connection_args=None, suppress_consec_slashes=True, version_id=None, generation=None, is_latest=False):
self.scheme = scheme self.bucket_name = bucket_name self.object_name = object_name self.debug = debug if connection_args: self.connection_args = connection_args self.suppress_consec_slashes = suppress_consec_slashes self.version_id = version_id self.generation = (generation and i...
'Instantiate a BucketStorageUri from the current BucketStorageUri, but replacing the object_name. @type new_name: string @param new_name: new object name'
def clone_replace_name(self, new_name):
self._check_bucket_uri('clone_replace_name') return BucketStorageUri(self.scheme, bucket_name=self.bucket_name, object_name=new_name, debug=self.debug, suppress_consec_slashes=self.suppress_consec_slashes)
'Instantiate a BucketStorageUri from the current BucketStorageUri, by replacing the object name with the object name and other metadata found in the given Key object (including generation). @type key: Key @param key: key for the new StorageUri to represent'
def clone_replace_key(self, key):
self._check_bucket_uri('clone_replace_key') version_id = None generation = None is_latest = False if hasattr(key, 'version_id'): version_id = key.version_id if hasattr(key, 'generation'): generation = key.generation if hasattr(key, 'is_latest'): is_latest = key.is_lat...
'returns a bucket\'s acl'
def get_acl(self, validate=False, headers=None, version_id=None):
self._check_bucket_uri('get_acl') bucket = self.get_bucket(validate, headers) key_name = (self.object_name or '') if (self.get_provider().name == 'aws'): version_id = (version_id or self.version_id) acl = bucket.get_acl(key_name, headers, version_id) else: acl = bucket.get_ac...
'returns a bucket\'s default object acl'
def get_def_acl(self, validate=False, headers=None):
self._check_bucket_uri('get_def_acl') bucket = self.get_bucket(validate, headers) acl = bucket.get_def_acl(headers) self.check_response(acl, 'acl', self.uri) return acl
'returns a bucket\'s CORS XML'
def get_cors(self, validate=False, headers=None):
self._check_bucket_uri('get_cors') bucket = self.get_bucket(validate, headers) cors = bucket.get_cors(headers) self.check_response(cors, 'cors', self.uri) return cors
'sets or updates a bucket\'s CORS XML'
def set_cors(self, cors, validate=False, headers=None):
self._check_bucket_uri('set_cors ') bucket = self.get_bucket(validate, headers) if (self.scheme == 's3'): bucket.set_cors(cors, headers) else: bucket.set_cors(cors.to_xml(), headers)
'Updates a bucket\'s storage class.'
def set_storage_class(self, storage_class, validate=False, headers=None):
self._check_bucket_uri('set_storage_class') if (self.scheme != 'gs'): raise ValueError(('set_storage_class() not supported for %s URIs.' % self.scheme)) bucket = self.get_bucket(validate, headers) bucket.set_storage_class(storage_class, headers)
'Returns True if this URI names a file or directory.'
def is_file_uri(self):
return False
'Returns True if this URI names a bucket or object.'
def is_cloud_uri(self):
return True
'Returns True if this URI names a directory or bucket. Will return False for bucket subdirs; providing bucket subdir semantics needs to be done by the caller (like gsutil does).'
def names_container(self):
return bool((not self.object_name))
'Returns True if this URI names a file or object.'
def names_singleton(self):
return bool(self.object_name)
'Returns True if this URI names a directory.'
def names_directory(self):
return False
'Returns True if this URI names a provider.'
def names_provider(self):
return bool((not self.bucket_name))
'Returns True if this URI names a bucket.'
def names_bucket(self):
return (bool(self.bucket_name) and bool((not self.object_name)))
'Returns True if this URI names a file.'
def names_file(self):
return False
'Returns True if this URI names an object.'
def names_object(self):
return self.names_singleton()
'Returns True if this URI represents input/output stream.'
def is_stream(self):
return False
'Sets or updates a bucket\'s ACL.'
def set_acl(self, acl_or_str, key_name='', validate=False, headers=None, version_id=None, if_generation=None, if_metageneration=None):
self._check_bucket_uri('set_acl') key_name = (key_name or self.object_name or '') bucket = self.get_bucket(validate, headers) if self.generation: bucket.set_acl(acl_or_str, key_name, headers, generation=self.generation, if_generation=if_generation, if_metageneration=if_metageneration) else: ...
'Sets or updates a bucket\'s ACL with an XML string.'
def set_xml_acl(self, xmlstring, key_name='', validate=False, headers=None, version_id=None, if_generation=None, if_metageneration=None):
self._check_bucket_uri('set_xml_acl') key_name = (key_name or self.object_name or '') bucket = self.get_bucket(validate, headers) if self.generation: bucket.set_xml_acl(xmlstring, key_name, headers, generation=self.generation, if_generation=if_generation, if_metageneration=if_metageneration) ...
'Sets or updates a bucket\'s default object ACL with an XML string.'
def set_def_xml_acl(self, xmlstring, validate=False, headers=None):
self._check_bucket_uri('set_def_xml_acl') self.get_bucket(validate, headers).set_def_xml_acl(xmlstring, headers)
'Sets or updates a bucket\'s default object ACL.'
def set_def_acl(self, acl_or_str, validate=False, headers=None, version_id=None):
self._check_bucket_uri('set_def_acl') self.get_bucket(validate, headers).set_def_acl(acl_or_str, headers)
'Sets or updates a bucket\'s acl to a predefined (canned) value.'
def set_canned_acl(self, acl_str, validate=False, headers=None, version_id=None):
self._check_object_uri('set_canned_acl') self._warn_about_args('set_canned_acl', version_id=version_id) key = self.get_key(validate, headers) self.check_response(key, 'key', self.uri) key.set_canned_acl(acl_str, headers)
'Sets or updates a bucket\'s default object acl to a predefined (canned) value.'
def set_def_canned_acl(self, acl_str, validate=False, headers=None, version_id=None):
self._check_bucket_uri('set_def_canned_acl ') key = self.get_key(validate, headers) self.check_response(key, 'key', self.uri) key.set_def_canned_acl(acl_str, headers, version_id)
'Returns newly created key.'
def copy_key(self, src_bucket_name, src_key_name, metadata=None, src_version_id=None, storage_class='STANDARD', preserve_acl=False, encrypt_key=False, headers=None, query_args=None, src_generation=None):
self._check_object_uri('copy_key') dst_bucket = self.get_bucket(validate=False, headers=headers) if src_generation: return dst_bucket.copy_key(new_key_name=self.object_name, src_bucket_name=src_bucket_name, src_key_name=src_key_name, metadata=metadata, storage_class=storage_class, preserve_acl=prese...
'Returns a bucket\'s lifecycle configuration.'
def get_lifecycle_config(self, validate=False, headers=None):
self._check_bucket_uri('get_lifecycle_config') bucket = self.get_bucket(validate, headers) lifecycle_config = bucket.get_lifecycle_config(headers) self.check_response(lifecycle_config, 'lifecycle', self.uri) return lifecycle_config
'Sets or updates a bucket\'s lifecycle configuration.'
def configure_lifecycle(self, lifecycle_config, validate=False, headers=None):
self._check_bucket_uri('configure_lifecycle') bucket = self.get_bucket(validate, headers) bucket.configure_lifecycle(lifecycle_config, headers)
'Returns True if the object exists or False if it doesn\'t'
def exists(self, headers=None):
if (not self.object_name): raise InvalidUriError(('exists on object-less URI (%s)' % self.uri)) bucket = self.get_bucket() key = bucket.get_key(self.object_name, headers=headers) return bool(key)
'Instantiate a FileStorageUri from a path name. @type object_name: string @param object_name: object name @type debug: boolean @param debug: whether to enable debugging on this StorageUri After instantiation the components are available in the following fields: uri, scheme, bucket_name (always blank for this "anonymous...
def __init__(self, object_name, debug, is_stream=False):
self.scheme = 'file' self.bucket_name = '' self.object_name = object_name self.uri = ('file://' + object_name) self.debug = debug self.stream = is_stream
'Instantiate a FileStorageUri from the current FileStorageUri, but replacing the object_name. @type new_name: string @param new_name: new object name'
def clone_replace_name(self, new_name):
return FileStorageUri(new_name, self.debug, self.stream)
'Returns True if this URI names a file or directory.'
def is_file_uri(self):
return True
'Returns True if this URI names a bucket or object.'
def is_cloud_uri(self):
return False
'Returns True if this URI names a directory or bucket.'
def names_container(self):
return self.names_directory()
'Returns True if this URI names a file (or stream) or object.'
def names_singleton(self):
return (not self.names_container())
'Returns True if this URI names a directory.'
def names_directory(self):
if self.stream: return False return os.path.isdir(self.object_name)
'Returns True if this URI names a provider.'
def names_provider(self):
return False
'Returns True if this URI names a bucket.'
def names_bucket(self):
return False
'Returns True if this URI names a file.'
def names_file(self):
return self.names_singleton()
'Returns True if this URI names an object.'
def names_object(self):
return False
'Returns True if this URI represents input/output stream.'
def is_stream(self):
return bool(self.stream)
'Closes the underlying file.'
def close(self):
self.get_key().close()
'Returns True if the file exists or False if it doesn\'t'
def exists(self, _headers_not_used=None):
return os.path.exists(self.object_name)
'Retrieves a list of documents that match the specified search criteria. How you specify the search criteria depends on which query parser you use. Amazon CloudSearch supports four query parsers: + `simple`: search all `text` and `text-array` fields for the specified string. Search for phrases, individual terms, and pr...
def search(self, query, cursor=None, expr=None, facet=None, filter_query=None, highlight=None, partial=None, query_options=None, query_parser=None, ret=None, size=None, sort=None, start=None):
uri = '/2013-01-01/search' params = {} headers = {} query_params = {} if (cursor is not None): query_params['cursor'] = cursor if (expr is not None): query_params['expr'] = expr if (facet is not None): query_params['facet'] = facet if (filter_query is not None): ...
'Retrieves autocomplete suggestions for a partial query string. You can use suggestions enable you to display likely matches before users finish typing. In Amazon CloudSearch, suggestions are based on the contents of a particular text field. When you request suggestions, Amazon CloudSearch finds all of the documents wh...
def suggest(self, query, suggester, size=None):
uri = '/2013-01-01/suggest' params = {} headers = {} query_params = {} if (query is not None): query_params['q'] = query if (suggester is not None): query_params['suggester'] = suggester if (size is not None): query_params['size'] = size return self.make_request('...
'Posts a batch of documents to a search domain for indexing. A document batch is a collection of add and delete operations that represent the documents you want to add, update, or delete from your domain. Batches can be described in either JSON or XML. Each item that you want Amazon CloudSearch to return as a search re...
def upload_documents(self, documents, content_type):
uri = '/2013-01-01/documents/batch' headers = {} query_params = {} if (content_type is not None): headers['Content-Type'] = content_type return self.make_request('POST', uri, expected_status=200, data=documents, headers=headers, params=query_params)
':type anon: boolean :param anon: If this parameter is True, the ``STSConnection`` object will make anonymous requests, and it will not use AWS Credentials or even search for AWS Credentials to make these requests.'
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/', converter=None, validate_certs=True, anon=False, security_token=None, profile_name=None):
if (not region): region = RegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint, connection_cls=STSConnection) self.region = region self.anon = anon self._mutex = threading.Semaphore() provider = 'aws' if self.anon: provider = Provider('aws', NO_CREDENTIALS_PROVIDED...
'Return a valid session token. Because retrieving new tokens from the Secure Token Service is a fairly heavyweight operation this module caches previously retrieved tokens and returns them when appropriate. Each token is cached with a key consisting of the region name of the STS endpoint concatenated with the request...
def get_session_token(self, duration=None, force_new=False, mfa_serial_number=None, mfa_token=None):
token_key = ('%s:%s' % (self.region.name, self.provider.access_key)) token = self._check_token_cache(token_key, duration) if (force_new or (not token)): boto.log.debug(('fetching a new token for %s' % token_key)) try: self._mutex.acquire() token = self....
'Returns a set of temporary security credentials (consisting of an access key ID, a secret access key, and a security token) for a federated user. A typical use is in a proxy application that is getting temporary security credentials on behalf of distributed applications inside a corporate network. Because you must cal...
def get_federation_token(self, name, duration=None, policy=None):
params = {'Name': name} if duration: params['DurationSeconds'] = duration if policy: params['Policy'] = policy return self.get_object('GetFederationToken', params, FederationToken, verb='POST')
'Returns a set of temporary security credentials (consisting of an access key ID, a secret access key, and a security token) that you can use to access AWS resources that you might not normally have access to. Typically, you use `AssumeRole` for cross-account access or federation. For cross-account access, imagine that...
def assume_role(self, role_arn, role_session_name, policy=None, duration_seconds=None, external_id=None, mfa_serial_number=None, mfa_token=None):
params = {'RoleArn': role_arn, 'RoleSessionName': role_session_name} if (policy is not None): params['Policy'] = policy if (duration_seconds is not None): params['DurationSeconds'] = duration_seconds if (external_id is not None): params['ExternalId'] = external_id if (mfa_ser...
'Returns a set of temporary security credentials for users who have been authenticated via a SAML authentication response. This operation provides a mechanism for tying an enterprise identity store or directory to role-based AWS access without user-specific credentials or configuration. The temporary security credentia...
def assume_role_with_saml(self, role_arn, principal_arn, saml_assertion, policy=None, duration_seconds=None):
params = {'RoleArn': role_arn, 'PrincipalArn': principal_arn, 'SAMLAssertion': saml_assertion} if (policy is not None): params['Policy'] = policy if (duration_seconds is not None): params['DurationSeconds'] = duration_seconds return self.get_object('AssumeRoleWithSAML', params, AssumedRo...
'Returns a set of temporary security credentials for users who have been authenticated in a mobile or web application with a web identity provider, such as Login with Amazon, Facebook, or Google. `AssumeRoleWithWebIdentity` is an API call that does not require the use of AWS security credentials. Therefore, you can dis...
def assume_role_with_web_identity(self, role_arn, role_session_name, web_identity_token, provider_id=None, policy=None, duration_seconds=None):
params = {'RoleArn': role_arn, 'RoleSessionName': role_session_name, 'WebIdentityToken': web_identity_token} if (provider_id is not None): params['ProviderId'] = provider_id if (policy is not None): params['Policy'] = policy if (duration_seconds is not None): params['DurationSeco...
'Decodes additional information about the authorization status of a request from an encoded message returned in response to an AWS request. For example, if a user is not authorized to perform an action that he or she has requested, the request returns a `Client.UnauthorizedOperation` response (an HTTP 403 response). So...
def decode_authorization_message(self, encoded_message):
params = {'EncodedMessage': encoded_message} return self.get_object('DecodeAuthorizationMessage', params, DecodeAuthorizationMessage, verb='POST')
'Create and return a new Session Token based on the contents of a JSON document. :type json_doc: str :param json_doc: A string containing a JSON document with a previously saved Credentials object.'
@classmethod def from_json(cls, json_doc):
d = json.loads(json_doc) token = cls() token.__dict__.update(d) return token
'Create and return a new Session Token based on the contents of a previously saved JSON-format file. :type file_path: str :param file_path: The fully qualified path to the JSON-format file containing the previously saved Session Token information.'
@classmethod def load(cls, file_path):
fp = open(file_path) json_doc = fp.read() fp.close() return cls.from_json(json_doc)
'Return a Python dict containing the important information about this Session Token.'
def to_dict(self):
return {'access_key': self.access_key, 'secret_key': self.secret_key, 'session_token': self.session_token, 'expiration': self.expiration, 'request_id': self.request_id}
'Persist a Session Token to a file in JSON format. :type path: str :param path: The fully qualified path to the file where the the Session Token data should be written. Any previous data in the file will be overwritten. To help protect the credentials contained in the file, the permissions of the file will be set to ...
def save(self, file_path):
fp = open(file_path, 'w') json.dump(self.to_dict(), fp) fp.close() os.chmod(file_path, 384)