_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q255000 | BatchWebhooks.update | validation | def update(self, batch_webhook_id, data):
"""
Update a webhook that will fire whenever any batch request completes
processing.
:param batch_webhook_id: The unique id for the batch webhook.
:type batch_webhook_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"url": string*
}
"""
| python | {
"resource": ""
} |
q255001 | BatchWebhooks.delete | validation | def delete(self, batch_webhook_id):
"""
Remove a batch webhook. Webhooks will no longer be sent to the given
URL.
:param batch_webhook_id: The unique | python | {
"resource": ""
} |
q255002 | Stores.create | validation | def create(self, data):
"""
Add a new store to your MailChimp account.
Error checking on the currency code verifies that it is in the correct
three-letter, all-caps format as specified by ISO 4217 but does not
check that it is a valid code as the list of valid codes changes over
time.
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"id": string*,
"list_id": string*,
"name": string*,
"currency_code": string*
}
"""
if 'id' not in data:
raise KeyError('The store must have an id')
if 'list_id' not in data:
raise KeyError('The store must have a list_id')
if 'name' not in data:
raise KeyError('The store must have a name')
if 'currency_code' not in data:
raise KeyError('The store | python | {
"resource": ""
} |
q255003 | Stores.update | validation | def update(self, store_id, data):
"""
Update a store.
:param store_id: The store id.
:type store_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
"""
| python | {
"resource": ""
} |
q255004 | StoreProductImages.create | validation | def create(self, store_id, product_id, data):
"""
Add a new image to the product.
:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"id": string*,
"url": string*
}
"""
self.store_id = store_id
self.product_id = product_id
if 'id' not in data:
| python | {
"resource": ""
} |
q255005 | StoreProductImages.get | validation | def get(self, store_id, product_id, image_id, **queryparams):
"""
Get information about a specific product image.
:param store_id: The store id.
:type store_id: :py:class:`str`
:param product_id: The id for the product of a store.
:type product_id: :py:class:`str`
:param image_id: The id for | python | {
"resource": ""
} |
q255006 | ConversationMessages.create | validation | def create(self, conversation_id, data):
"""
Post a new message to a conversation.
:param conversation_id: The unique id for the conversation.
:type conversation_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"from_email": string*,
"read": boolean*
}
"""
self.conversation_id = conversation_id
if 'from_email' not in data:
raise KeyError('The conversation message must have a from_email')
check_email(data['from_email'])
if 'read' not in data:
raise KeyError('The conversation message must have | python | {
"resource": ""
} |
q255007 | StoreOrders.create | validation | def create(self, store_id, data):
"""
Add a new order to a store.
:param store_id: The store id.
:type store_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"id": string*,
"customer": object*
{
"'id": string*
},
"curency_code": string*,
"order_total": number*,
"lines": array*
[
{
"id": string*,
"product_id": string*,
"product_variant_id": string*,
"quantity": integer*,
"price": number*
}
]
}
"""
self.store_id = store_id
if 'id' not in data:
raise KeyError('The order must have an id')
if 'customer' not in data:
raise KeyError('The order must have a customer')
if 'id' not in data['customer']:
raise KeyError('The order customer must have an id')
if 'currency_code' not in data:
raise KeyError('The order must have a currency_code')
if not re.match(r"^[A-Z]{3}$", data['currency_code']):
raise ValueError('The currency_code must be a valid 3-letter ISO 4217 currency code')
if 'order_total' not in data:
raise KeyError('The order must have an order_total')
| python | {
"resource": ""
} |
q255008 | ListMemberNotes.create | validation | def create(self, list_id, subscriber_hash, data):
"""
Add a new note for a specific subscriber.
The documentation lists only the note request body parameter so it is
being documented and error-checked as if it were required based on the
description of the method.
:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
list member’s email address.
:type subscriber_hash: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"note": string*
} | python | {
"resource": ""
} |
q255009 | ListMemberTags.update | validation | def update(self, list_id, subscriber_hash, data):
"""
Update tags for a specific subscriber.
The documentation lists only the tags request body parameter so it is
being documented and error-checked as if it were required based on the
description of the method.
The data list needs to include a "status" key. This determines if the
tag should be added or removed from the user:
data = {
'tags': [
{'name': 'foo', 'status': 'active'},
{'name': 'bar', 'status': 'inactive'}
| python | {
"resource": ""
} |
q255010 | ListSegments.update | validation | def update(self, list_id, segment_id, data):
"""
Update a specific segment in a list.
:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param segment_id: The unique id for the segment.
:type segment_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"name": string*
}
"""
| python | {
"resource": ""
} |
q255011 | TemplateFolders.update | validation | def update(self, folder_id, data):
"""
Update a specific folder used to organize templates.
:param folder_id: The unique id for the File Manager folder.
:type folder_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"name": string*
}
"""
if 'name' not in data:
| python | {
"resource": ""
} |
q255012 | ListMembers.create | validation | def create(self, list_id, data):
"""
Add a new member to the list.
:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"status": string*, (Must be one of 'subscribed', 'unsubscribed', 'cleaned',
'pending', or 'transactional')
"email_address": string*
}
"""
self.list_id = list_id
if 'status' not in data:
raise KeyError('The list member must have a status')
if data['status'] not in ['subscribed', 'unsubscribed', 'cleaned', 'pending', 'transactional']:
raise ValueError('The list member status must be one of "subscribed", "unsubscribed", "cleaned", '
| python | {
"resource": ""
} |
q255013 | ListMembers.update | validation | def update(self, list_id, subscriber_hash, data):
"""
Update information for a specific list member.
:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
| python | {
"resource": ""
} |
q255014 | ListMembers.create_or_update | validation | def create_or_update(self, list_id, subscriber_hash, data):
"""
Add or update a list member.
:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
list member’s email address.
:type subscriber_hash: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"email_address": string*,
"status_if_new": string* (Must be one of 'subscribed',
'unsubscribed', 'cleaned', 'pending', or 'transactional')
}
"""
subscriber_hash = check_subscriber_hash(subscriber_hash)
self.list_id = list_id
self.subscriber_hash = subscriber_hash
if 'email_address' not in data:
| python | {
"resource": ""
} |
q255015 | ListMembers.delete | validation | def delete(self, list_id, subscriber_hash):
"""
Delete a member from a list.
:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
list member’s email address.
:type subscriber_hash: :py:class:`str`
| python | {
"resource": ""
} |
q255016 | ListMembers.delete_permanent | validation | def delete_permanent(self, list_id, subscriber_hash):
"""
Delete permanently a member from a list.
:param list_id: The unique id for the list.
:type list_id: :py:class:`str`
:param subscriber_hash: The MD5 hash of the lowercase version of the
list member’s email address.
:type subscriber_hash: :py:class:`str`
| python | {
"resource": ""
} |
q255017 | AutomationEmailActions.pause | validation | def pause(self, workflow_id, email_id):
"""
Pause an automated email.
:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`
:param email_id: The unique id for the Automation workflow email.
:type email_id: :py:class:`str`
""" | python | {
"resource": ""
} |
q255018 | AutomationEmailActions.start | validation | def start(self, workflow_id, email_id):
"""
Start an automated email.
:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`
:param email_id: The unique id for the Automation workflow email.
:type email_id: :py:class:`str`
""" | python | {
"resource": ""
} |
q255019 | AutomationEmailActions.delete | validation | def delete(self, workflow_id, email_id):
"""
Removes an individual Automation workflow email.
:param workflow_id: The unique id for the Automation workflow.
:type workflow_id: :py:class:`str`
:param email_id: The unique id for the Automation workflow email.
:type email_id: :py:class:`str`
| python | {
"resource": ""
} |
q255020 | Campaigns.create | validation | def create(self, data):
"""
Create a new MailChimp campaign.
The ValueError raised by an invalid type in data does not mention
'absplit' as a potential value because the documentation indicates
that the absplit type has been deprecated.
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"recipients": object*
{
"list_id": string*
},
"settings": object*
{
"subject_line": string*,
"from_name": string*,
"reply_to": string*
},
"variate_settings": object* (Required if type is "variate")
{
"winner_criteria": string* (Must be one of "opens", "clicks", "total_revenue", or "manual")
},
"rss_opts": object* (Required if type is "rss")
{
"feed_url": string*,
"frequency": string* (Must be one of "daily", "weekly", or "monthly")
},
"type": string* (Must be one of "regular", "plaintext", "rss", "variate", or "absplit")
}
"""
if 'recipients' not in data:
raise KeyError('The campaign must have recipients')
if 'list_id' not in data['recipients']:
raise KeyError('The campaign recipients must have a list_id')
if 'settings' not in data:
raise KeyError('The campaign must have settings')
if 'subject_line' not in data['settings']:
raise KeyError('The campaign settings must have a subject_line')
if 'from_name' not in data['settings']:
raise KeyError('The campaign settings must have a from_name')
if 'reply_to' not in data['settings']:
raise KeyError('The campaign settings must have a reply_to')
check_email(data['settings']['reply_to'])
if 'type' not in data:
raise KeyError('The campaign must have a type')
if not data['type'] in ['regular', 'plaintext', 'rss', 'variate', 'abspilt']:
raise ValueError('The campaign type must be one of "regular", "plaintext", "rss", or "variate"')
if data['type'] == 'variate':
if 'variate_settings' not in data:
raise KeyError('The variate campaign must have variate_settings')
if 'winner_criteria' not in data['variate_settings']:
| python | {
"resource": ""
} |
q255021 | Campaigns.update | validation | def update(self, campaign_id, data):
"""
Update some or all of the settings for a specific campaign.
:param campaign_id: The unique id for the campaign.
:type campaign_id: :py:class:`str`
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"settings": object*
{
"subject_line": string*,
"from_name": string*,
"reply_to": string*
},
}
"""
self.campaign_id = campaign_id
if 'settings' not in data:
raise KeyError('The campaign must | python | {
"resource": ""
} |
q255022 | Campaigns.delete | validation | def delete(self, campaign_id):
"""
Remove a campaign from your MailChimp account.
:param campaign_id: The unique id | python | {
"resource": ""
} |
q255023 | StoreCartLines.delete | validation | def delete(self, store_id, cart_id, line_id):
"""
Delete a cart.
:param store_id: The store id.
:type store_id: :py:class:`str`
:param cart_id: The id for the cart.
:type cart_id: :py:class:`str`
:param line_id: The id for the line item of a cart.
:type line_id: :py:class:`str`
| python | {
"resource": ""
} |
q255024 | BatchOperations.create | validation | def create(self, data):
"""
Begin processing a batch operations request.
:param data: The request body parameters
:type data: :py:class:`dict`
data = {
"operations": array*
[
{
"method": string* (Must be one of "GET", "POST", "PUT", "PATCH", or "DELETE")
"path": string*,
}
]
}
"""
if 'operations' not in data:
raise KeyError('The batch must have operations')
for op in data['operations']:
if 'method' not in op:
raise KeyError('The batch | python | {
"resource": ""
} |
q255025 | BatchOperations.all | validation | def all(self, get_all=False, **queryparams):
"""
Get a summary of batch requests that have been made.
:param get_all: Should the query get all results
:type get_all: :py:class:`bool`
:param queryparams: The query string parameters
queryparams['fields'] | python | {
"resource": ""
} |
q255026 | BatchOperations.get | validation | def get(self, batch_id, **queryparams):
"""
Get the status of a batch request.
:param batch_id: The unique id for the batch operation.
:type batch_id: :py:class:`str`
:param queryparams: The query string parameters
queryparams['fields'] = []
queryparams['exclude_fields'] = [] | python | {
"resource": ""
} |
q255027 | BatchOperations.delete | validation | def delete(self, batch_id):
"""
Stops a batch request from running. Since only one batch request is
run at a time, this can be used to cancel a long running request. The
results of any completed operations will not be available after this
call.
:param batch_id: The unique id for the batch operation.
| python | {
"resource": ""
} |
q255028 | _reformat_policy | validation | def _reformat_policy(policy):
"""
Policies returned from boto3 are massive, ugly, and difficult to read.
This method flattens and reformats the policy.
:param policy: Result from invoking describe_load_balancer_policies(...)
:return: Returns a tuple containing policy_name and the reformatted policy dict.
"""
policy_name = policy['PolicyName']
ret = {}
ret['type'] = policy['PolicyTypeName']
attrs = policy['PolicyAttributeDescriptions']
if ret['type'] != 'SSLNegotiationPolicyType':
return policy_name, ret
attributes = dict()
for attr in attrs:
attributes[attr['AttributeName']] = attr['AttributeValue']
ret['protocols'] = dict()
ret['protocols']['sslv2'] = bool(attributes.get('Protocol-SSLv2'))
ret['protocols']['sslv3'] = bool(attributes.get('Protocol-SSLv3'))
ret['protocols']['tlsv1'] = bool(attributes.get('Protocol-TLSv1'))
ret['protocols']['tlsv1_1'] = bool(attributes.get('Protocol-TLSv1.1'))
ret['protocols']['tlsv1_2'] = | python | {
"resource": ""
} |
q255029 | get_load_balancer | validation | def get_load_balancer(load_balancer, flags=FLAGS.ALL ^ FLAGS.POLICY_TYPES, **conn):
"""
Fully describes an ELB.
:param loadbalancer: Could be an ELB Name or a dictionary. Likely the return value from a previous call to describe_load_balancers. At a minimum, must contain a key titled 'LoadBalancerName'.
:param flags: Flags describing which sections should be included in the return value. Default is FLAGS.ALL minus FLAGS.POLICY_TYPES.
:return: Returns a dictionary describing the ELB with the fields described in the flags parameter.
| python | {
"resource": ""
} |
q255030 | GCPCache.get | validation | def get(self, key, delete_if_expired=True):
"""
Retrieve key from Cache.
:param key: key to look up in cache.
:type key: ``object``
:param delete_if_expired: remove value from cache if it is expired.
Default is True.
:type delete_if_expired: ``bool``
:returns: value from cache or None
:rtype: varies or None
"""
self._update_cache_stats(key, None)
if key in self._CACHE:
(expiration, obj) = self._CACHE[key]
| python | {
"resource": ""
} |
q255031 | GCPCache.insert | validation | def insert(self, key, obj, future_expiration_minutes=15):
"""
Insert item into cache.
:param key: key to look up in cache.
:type key: ``object``
:param obj: item to store in cache.
:type obj: varies
:param future_expiration_minutes: number of minutes item is valid
:type param: ``int`` | python | {
"resource": ""
} |
q255032 | GCPCache._update_cache_stats | validation | def _update_cache_stats(self, key, result):
"""
Update the cache stats.
If no cache-result is specified, we iniitialize the key.
Otherwise, we increment the correct cache-result.
Note the behavior for expired. A client can be expired and the key
still exists.
"""
| python | {
"resource": ""
} |
q255033 | GCPCache.get_access_details | validation | def get_access_details(self, key=None):
"""Get access details in cache."""
if key in | python | {
"resource": ""
} |
q255034 | GCPCache.get_stats | validation | def get_stats(self):
"""Get general stats for the cache."""
expired = sum([x['expired'] for _, x in
self._CACHE_STATS['access_stats'].items()])
miss = sum([x['miss'] for _, x in
self._CACHE_STATS['access_stats'].items()])
| python | {
"resource": ""
} |
q255035 | get_vpc_flow_logs | validation | def get_vpc_flow_logs(vpc, **conn):
"""Gets the VPC Flow Logs for a VPC"""
fl_result = describe_flow_logs(Filters=[{"Name": "resource-id", "Values": [vpc["id"]]}], **conn)
| python | {
"resource": ""
} |
q255036 | get_classic_link | validation | def get_classic_link(vpc, **conn):
"""Gets the Classic Link details about a VPC"""
result = {}
try:
cl_result = describe_vpc_classic_link(VpcIds=[vpc["id"]], **conn)[0]
result["Enabled"] = cl_result["ClassicLinkEnabled"]
# Check for DNS as well:
dns_result = describe_vpc_classic_link_dns_support(VpcIds=[vpc["id"]], **conn)[0]
result["DnsEnabled"] | python | {
"resource": ""
} |
q255037 | get_subnets | validation | def get_subnets(vpc, **conn):
"""Gets the VPC Subnets"""
subnets = describe_subnets(Filters=[{"Name": "vpc-id", "Values": [vpc["id"]]}], **conn)
| python | {
"resource": ""
} |
q255038 | get_route_tables | validation | def get_route_tables(vpc, **conn):
"""Gets the VPC Route Tables"""
route_tables = describe_route_tables(Filters=[{"Name": "vpc-id", | python | {
"resource": ""
} |
q255039 | get_network_acls | validation | def get_network_acls(vpc, **conn):
"""Gets the VPC Network ACLs"""
route_tables = describe_network_acls(Filters=[{"Name": "vpc-id", | python | {
"resource": ""
} |
q255040 | get_client | validation | def get_client(service, service_type='client', **conn_args):
"""
User function to get the correct client.
Based on the GOOGLE_CLIENT_MAP dictionary, the return will be a cloud or general
client that can interact with the desired service.
:param service: GCP service to connect to. E.g. 'gce', 'iam'
:type service: ``str``
:param conn_args: Dictionary of connection arguments. 'project' is required.
'user_agent' can be specified and will be set in the client
returned.
:type conn_args: ``dict``
:return: client_details, client
:rtype: ``tuple`` of ``dict``, ``object``
"""
client_details = choose_client(service)
user_agent = get_user_agent(**conn_args)
if client_details:
if client_details['client_type'] == 'cloud':
client = get_gcp_client(
mod_name=client_details['module_name'],
pkg_name=conn_args.get('pkg_name', 'google.cloud'),
key_file=conn_args.get('key_file', None),
project=conn_args['project'], user_agent=user_agent)
else:
client = get_google_client(
| python | {
"resource": ""
} |
q255041 | get_gcp_client | validation | def get_gcp_client(**kwargs):
"""Public GCP client builder."""
return _gcp_client(project=kwargs['project'], mod_name=kwargs['mod_name'],
pkg_name=kwargs.get('pkg_name', 'google.cloud'),
key_file=kwargs.get('key_file', None),
| python | {
"resource": ""
} |
q255042 | _gcp_client | validation | def _gcp_client(project, mod_name, pkg_name, key_file=None, http_auth=None,
user_agent=None):
"""
Private GCP client builder.
:param project: Google Cloud project string.
:type project: ``str``
:param mod_name: Module name to load. Should be found in sys.path.
:type mod_name: ``str``
:param pkg_name: package name that mod_name is part of. Default is 'google.cloud' .
:type pkg_name: ``str``
:param key_file: Default is None.
:type key_file: ``str`` or None
:param http_auth: httplib2 authorized client. Default is None.
:type http_auth: :class: `HTTPLib2`
:param user_agent: User Agent string to use in requests. Default is None.
:type http_auth: ``str`` or None
:return: GCP client
:rtype: ``object``
"""
client = None
if http_auth is None:
http_auth = _googleauth(key_file=key_file, user_agent=user_agent)
try:
# Using a relative path, so we prefix with a dot (.)
google_module = importlib.import_module('.' + mod_name,
| python | {
"resource": ""
} |
q255043 | _googleauth | validation | def _googleauth(key_file=None, scopes=[], user_agent=None):
"""
Google http_auth helper.
If key_file is not specified, default credentials will be used.
If scopes is specified (and key_file), will be used instead of DEFAULT_SCOPES
:param key_file: path to key file to use. Default is None
:type key_file: ``str``
:param scopes: scopes to set. Default is DEFAUL_SCOPES
:type scopes: ``list``
:param user_agent: User Agent string to use in requests. Default is None.
:type http_auth: ``str`` or None
:return: HTTPLib2 authorized client.
:rtype: :class: `HTTPLib2`
"""
if key_file:
if not scopes:
| python | {
"resource": ""
} |
q255044 | _build_google_client | validation | def _build_google_client(service, api_version, http_auth):
"""
Google build client helper.
:param service: service to build client for
:type service: ``str``
:param api_version: API version to use. | python | {
"resource": ""
} |
q255045 | iter_project | validation | def iter_project(projects, key_file=None):
"""
Call decorated function for each item in project list.
Note: the function 'decorated' is expected to return a value plus a dictionary of exceptions.
If item in list is a dictionary, we look for a 'project' and 'key_file' entry, respectively.
If item in list is of type string_types, we assume it is the project string. Default credentials
will be used by the underlying client library.
:param projects: list of project strings or list of dictionaries
Example: {'project':..., 'keyfile':...}. Required.
:type projects: ``list`` of ``str`` or ``list`` of ``dict``
:param key_file: path on disk to keyfile, for use with all projects
:type key_file: ``str``
:returns: tuple containing a list of function output and an exceptions map
:rtype: ``tuple of ``list``, ``dict``
"""
def decorator(func):
@wraps(func)
def decorated_function(*args, **kwargs):
item_list = []
exception_map = {}
for project in projects:
if isinstance(project, string_types):
| python | {
"resource": ""
} |
q255046 | get_creds_from_kwargs | validation | def get_creds_from_kwargs(kwargs):
"""Helper to get creds out of kwargs."""
creds = {
'key_file': kwargs.pop('key_file', None),
'http_auth': kwargs.pop('http_auth', None),
'project': kwargs.get('project', None),
| python | {
"resource": ""
} |
q255047 | rewrite_kwargs | validation | def rewrite_kwargs(conn_type, kwargs, module_name=None):
"""
Manipulate connection keywords.
Modifieds keywords based on connection type.
There is an assumption here that the client has
already been created and that these keywords are being
passed into methods for interacting with various services.
Current modifications:
- if conn_type is not cloud and module is 'compute',
then rewrite project as name.
- if conn_type is cloud and module is 'storage',
then remove 'project' from dict.
:param conn_type: E.g. 'cloud' or 'general'
:type conn_type: ``str``
:param kwargs: Dictionary of keywords sent in by user.
:type kwargs: ``dict``
:param module_name: Name of specific module that will be loaded.
| python | {
"resource": ""
} |
q255048 | gce_list_aggregated | validation | def gce_list_aggregated(service=None, key_name='name', **kwargs):
"""General aggregated list function for the GCE service."""
resp_list = []
req = service.aggregatedList(**kwargs)
while req is not None:
resp = req.execute()
for location, item in resp['items'].items():
| python | {
"resource": ""
} |
q255049 | gce_list | validation | def gce_list(service=None, **kwargs):
"""General list function for the GCE service."""
resp_list = []
req = service.list(**kwargs)
while req is not None:
resp = req.execute()
for item in resp.get('items', []):
| python | {
"resource": ""
} |
q255050 | service_list | validation | def service_list(service=None, key_name=None, **kwargs):
"""General list function for Google APIs."""
resp_list = []
req = service.list(**kwargs)
while req is not None:
resp = req.execute()
if key_name and key_name in resp:
| python | {
"resource": ""
} |
q255051 | get_cache_access_details | validation | def get_cache_access_details(key=None):
"""Retrieve detailed cache information.""" | python | {
"resource": ""
} |
q255052 | get_user_agent_default | validation | def get_user_agent_default(pkg_name='cloudaux'):
"""
Get default User Agent String.
Try to import pkg_name to get an accurate version number.
return: string
"""
version = '0.0.1'
try:
import pkg_resources
version | python | {
"resource": ""
} |
q255053 | list_rules | validation | def list_rules(client=None, **kwargs):
"""
NamePrefix='string'
"""
result = client.list_rules(**kwargs)
if not | python | {
"resource": ""
} |
q255054 | list_targets_by_rule | validation | def list_targets_by_rule(client=None, **kwargs):
"""
Rule='string'
"""
result | python | {
"resource": ""
} |
q255055 | list_buckets | validation | def list_buckets(client=None, **kwargs):
"""
List buckets for a project.
:param client: client object to use.
:type client: Google Cloud Storage client
:returns: list of dictionary reprsentation of Bucket
| python | {
"resource": ""
} |
q255056 | list_objects_in_bucket | validation | def list_objects_in_bucket(**kwargs):
"""
List objects in bucket.
:param Bucket: name of bucket
:type Bucket: ``str``
:returns list of objects in bucket
:rtype: ``list``
| python | {
"resource": ""
} |
q255057 | modify | validation | def modify(item, output='camelized'):
"""
Calls _modify and either passes the inflection.camelize method or the inflection.underscore method.
:param item: dictionary representing item | python | {
"resource": ""
} |
q255058 | get_role_managed_policy_documents | validation | def get_role_managed_policy_documents(role, client=None, **kwargs):
"""Retrieve the currently active policy version document for every managed policy that is attached to the role."""
policies = get_role_managed_policies(role, force_client=client)
policy_names = (policy['name'] for policy in policies)
delayed_gmpd_calls = | python | {
"resource": ""
} |
q255059 | get_group | validation | def get_group(group_name, users=True, client=None, **kwargs):
"""Get's the IAM Group details.
:param group_name:
:param users: Optional -- will return the IAM users that the group is attached to if desired (paginated).
:param client:
:param kwargs:
:return:
"""
# First, make the initial call to get the details for the group:
result = client.get_group(GroupName=group_name, **kwargs)
# If we care about the user details, then fetch them:
if users:
if result.get('IsTruncated'):
kwargs_to_send = {'GroupName': group_name}
kwargs_to_send.update(kwargs)
| python | {
"resource": ""
} |
q255060 | get_group_policy_document | validation | def get_group_policy_document(group_name, policy_name, client=None, **kwargs):
"""Fetches the specific IAM group inline-policy document."""
return | python | {
"resource": ""
} |
q255061 | _get_base | validation | def _get_base(server_certificate, **conn):
"""Fetch the base IAM Server Certificate."""
server_certificate['_version'] = 1
# Get the initial cert details:
cert_details = get_server_certificate_api(server_certificate['ServerCertificateName'], **conn)
if cert_details:
server_certificate.update(cert_details['ServerCertificateMetadata'])
server_certificate['CertificateBody'] = cert_details['CertificateBody']
server_certificate['CertificateChain'] = cert_details.get('CertificateChain', None)
# Cast dates from | python | {
"resource": ""
} |
q255062 | boto3_cached_conn | validation | def boto3_cached_conn(service, service_type='client', future_expiration_minutes=15, account_number=None,
assume_role=None, session_name='cloudaux', region='us-east-1', return_credentials=False,
external_id=None, arn_partition='aws'):
"""
Used to obtain a boto3 client or resource connection.
For cross account, provide both account_number and assume_role.
:usage:
# Same Account:
client = boto3_cached_conn('iam')
resource = boto3_cached_conn('iam', service_type='resource')
# Cross Account Client:
client = boto3_cached_conn('iam', account_number='000000000000', assume_role='role_name')
# Cross Account Resource:
resource = boto3_cached_conn('iam', service_type='resource', account_number='000000000000', assume_role='role_name')
:param service: AWS service (i.e. 'iam', 'ec2', 'kms')
:param service_type: 'client' or 'resource'
:param future_expiration_minutes: Connections will expire from the cache
when their expiration is within this many minutes of the present time. [Default 15]
:param account_number: Required if assume_role is provided.
:param assume_role: Name of the role to assume into for account described by account_number.
:param session_name: Session name to attach to requests. [Default 'cloudaux']
:param region: Region name for connection. [Default us-east-1]
:param return_credentials: Indicates if the STS credentials should be returned with the client [Default False]
:param external_id: Optional external id to pass to sts:AssumeRole.
See https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html
:param arn_partition: Optional parameter to specify other aws partitions such as aws-us-gov for aws govcloud
:return: boto3 client or resource connection
"""
key = (
account_number,
assume_role,
session_name,
external_id,
| python | {
"resource": ""
} |
q255063 | get_rules | validation | def get_rules(security_group, **kwargs):
""" format the rule fields to match AWS to support auditor reuse,
will need to remap back if we want to orchestrate from our stored items """
rules = security_group.pop('security_group_rules',[])
for rule in rules:
rule['ip_protocol'] = rule.pop('protocol')
rule['from_port'] = rule.pop('port_range_max')
| python | {
"resource": ""
} |
q255064 | get_security_group | validation | def get_security_group(security_group, flags=FLAGS.ALL, **kwargs):
result = registry.build_out(flags, start_with=security_group, pass_datastructure=True, **kwargs)
""" just | python | {
"resource": ""
} |
q255065 | get_inline_policies | validation | def get_inline_policies(group, **conn):
"""Get the inline policies for the group."""
policy_list = list_group_policies(group['GroupName'])
policy_documents = {}
for policy in policy_list:
| python | {
"resource": ""
} |
q255066 | get_managed_policies | validation | def get_managed_policies(group, **conn):
"""Get a list of the managed policy names that are attached to the group."""
managed_policies = list_attached_group_managed_policies(group['GroupName'], **conn) | python | {
"resource": ""
} |
q255067 | get_users | validation | def get_users(group, **conn):
"""Gets a list of the usernames that are a part of this group."""
group_details = get_group_api(group['GroupName'], **conn)
user_list = []
for user in | python | {
"resource": ""
} |
q255068 | _get_base | validation | def _get_base(group, **conn):
"""Fetch the base IAM Group."""
group['_version'] = 1
# Get the initial group details (only needed if we didn't grab the users): | python | {
"resource": ""
} |
q255069 | get_base | validation | def get_base(managed_policy, **conn):
"""Fetch the base Managed Policy.
This includes the base policy and the latest version document.
:param managed_policy:
:param conn:
:return:
"""
managed_policy['_version'] = 1
arn = _get_name_from_structure(managed_policy, 'Arn')
policy = get_policy(arn, **conn)
document = get_managed_policy_document(arn, policy_metadata=policy, **conn) | python | {
"resource": ""
} |
q255070 | Catalog.get_short_version | validation | def get_short_version(self):
'''obtain the shory geoserver version
'''
gs_version = self.get_version()
| python | {
"resource": ""
} |
q255071 | Catalog.save | validation | def save(self, obj, content_type="application/xml"):
"""
saves an object to the REST service
gets the object's REST location and the data from the object,
then POSTS the request.
"""
rest_url = obj.href
data = obj.message()
headers = {
"Content-type": content_type,
"Accept": content_type
}
| python | {
"resource": ""
} |
q255072 | Catalog.get_stores | validation | def get_stores(self, names=None, workspaces=None):
'''
Returns a list of stores in the catalog. If workspaces is specified will only return stores in those workspaces.
If names is specified, will only return stores that match.
names can either be a comma delimited string or an array.
Will return an empty list if no stores are found.
'''
if isinstance(workspaces, Workspace):
workspaces = [workspaces]
elif isinstance(workspaces, list) and [w for w in workspaces if isinstance(w, Workspace)]:
# nothing
| python | {
"resource": ""
} |
q255073 | Catalog.get_store | validation | def get_store(self, name, workspace=None):
'''
Returns a single store object.
Will return None if no store is found.
Will raise an error if more than one store with the same name is found.
'''
| python | {
"resource": ""
} |
q255074 | Catalog.delete_granule | validation | def delete_granule(self, coverage, store, granule_id, workspace=None):
'''Deletes a granule of an existing imagemosaic'''
params = dict()
workspace_name = workspace
if isinstance(store, basestring):
store_name = store
else:
store_name = store.name
workspace_name = store.workspace.name
if workspace_name is None:
raise ValueError("Must specify workspace")
url = build_url(
self.service_url,
[
"workspaces",
workspace_name,
"coveragestores",
store_name,
"coverages",
coverage,
"index/granules",
granule_id,
".json"
],
| python | {
"resource": ""
} |
q255075 | Catalog.list_granules | validation | def list_granules(self, coverage, store, workspace=None, filter=None, limit=None, offset=None):
'''List granules of an imagemosaic'''
params = dict()
if filter is not None:
params['filter'] = filter
if limit is not None:
params['limit'] = limit
if offset is not None:
params['offset'] = offset
workspace_name = workspace
if isinstance(store, basestring):
store_name = store
else:
store_name = store.name
workspace_name = store.workspace.name
if workspace_name is None:
raise ValueError("Must specify workspace")
url = build_url(
self.service_url,
[
"workspaces",
workspace_name,
"coveragestores",
store_name,
"coverages",
| python | {
"resource": ""
} |
q255076 | Catalog.mosaic_coverages | validation | def mosaic_coverages(self, store):
'''Returns all coverages in a coverage store'''
params = dict()
url = build_url(
self.service_url,
[
"workspaces",
store.workspace.name,
"coveragestores",
store.name,
"coverages.json"
],
params
)
# GET /workspaces/<ws>/coveragestores/<name>/coverages.json
headers = {
"Content-type": "application/json",
| python | {
"resource": ""
} |
q255077 | Catalog.publish_featuretype | validation | def publish_featuretype(self, name, store, native_crs, srs=None, jdbc_virtual_table=None, native_name=None):
'''Publish a featuretype from data in an existing store'''
# @todo native_srs doesn't seem to get detected, even when in the DB
# metadata (at least for postgis in geometry_columns) and then there
# will be a misconfigured layer
if native_crs is None:
raise ValueError("must specify native_crs")
srs = srs or native_crs
feature_type = FeatureType(self, store.workspace, store, name)
# because name is the in FeatureType base class, work around that
# and hack in these others that don't have xml properties
feature_type.dirty['name'] = name
feature_type.dirty['srs'] = srs
feature_type.dirty['nativeCRS'] = native_crs
feature_type.enabled = True
feature_type.advertised = True
feature_type.title = name
if native_name is not None:
feature_type.native_name = native_name
headers = {
"Content-type": "application/xml",
"Accept": "application/xml"
}
resource_url = store.resource_url
if jdbc_virtual_table is not None:
| python | {
"resource": ""
} |
q255078 | Catalog.get_resources | validation | def get_resources(self, names=None, stores=None, workspaces=None):
'''
Resources include feature stores, coverage stores and WMS stores, however does not include layer groups.
names, stores and workspaces can be provided as a comma delimited strings or as arrays, and are used for filtering.
Will always return an array.
'''
stores = self.get_stores(
| python | {
"resource": ""
} |
q255079 | Catalog.get_resource | validation | def get_resource(self, name=None, store=None, workspace=None):
'''
returns a single resource object.
Will return None if no resource is found.
Will raise an error if more than one resource with the same name is found.
'''
| python | {
"resource": ""
} |
q255080 | Catalog.get_layergroup | validation | def get_layergroup(self, name, workspace=None):
'''
returns a single layergroup object.
Will return None if no layergroup is found.
Will raise an error if more than one layergroup with the same name is found.
'''
| python | {
"resource": ""
} |
q255081 | Catalog.get_style | validation | def get_style(self, name, workspace=None):
'''
returns a single style object.
Will return None if no style is found.
Will raise an error if more than one style with the same name is found.
'''
| python | {
"resource": ""
} |
q255082 | Catalog.get_workspaces | validation | def get_workspaces(self, names=None):
'''
Returns a list of workspaces in the catalog.
If names is specified, will only return workspaces that match.
names can either be a comma delimited string or an array.
Will return an empty list if no workspaces are found.
'''
if names is None:
names = []
elif isinstance(names, basestring):
names = [s.strip() for s in names.split(',') if s.strip()]
data = self.get_xml("{}/workspaces.xml".format(self.service_url))
| python | {
"resource": ""
} |
q255083 | Catalog.get_workspace | validation | def get_workspace(self, name):
'''
returns a single workspace object.
Will return None if no workspace is found.
Will raise an error if more than one workspace with the same name is found.
'''
| python | {
"resource": ""
} |
q255084 | md_link | validation | def md_link(node):
"""Extract a metadata link tuple from an xml node"""
mimetype = node.find("type")
mdtype = node.find("metadataType")
| python | {
"resource": ""
} |
q255085 | build_url | validation | def build_url(base, seg, query=None):
"""
Create a URL from a list of path segments and an optional dict of query
parameters.
"""
def clean_segment(segment):
"""
Cleans the segment and encodes to UTF-8 if the segment is unicode.
"""
segment = segment.strip('/')
if isinstance(segment, basestring):
segment = segment.encode('utf-8')
| python | {
"resource": ""
} |
q255086 | prepare_upload_bundle | validation | def prepare_upload_bundle(name, data):
"""GeoServer's REST API uses ZIP archives as containers for file formats such
as Shapefile and WorldImage which include several 'boxcar' files alongside
the main data. In such archives, GeoServer assumes that all of the relevant
files will have the same base name and appropriate extensions, and live in
the root of the ZIP archive. This method produces | python | {
"resource": ""
} |
q255087 | md_dimension_info | validation | def md_dimension_info(name, node):
"""Extract metadata Dimension Info from an xml node"""
def _get_value(child_name):
return getattr(node.find(child_name), 'text', None)
resolution = _get_value('resolution')
defaultValue = node.find("defaultValue")
strategy = defaultValue.find("strategy") if defaultValue is not None else | python | {
"resource": ""
} |
q255088 | md_dynamic_default_values_info | validation | def md_dynamic_default_values_info(name, node):
"""Extract metadata Dynamic Default Values from an xml node"""
configurations = node.find("configurations")
if configurations is not None:
configurations = []
for n in node.findall("configuration"):
dimension = n.find("dimension")
dimension = dimension.text if dimension is not None else None
policy = n.find("policy")
policy = policy.text if policy is not None else None
defaultValueExpression = n.find("defaultValueExpression")
| python | {
"resource": ""
} |
q255089 | md_jdbc_virtual_table | validation | def md_jdbc_virtual_table(key, node):
"""Extract metadata JDBC Virtual Tables from an xml node"""
name = node.find("name")
sql = node.find("sql")
escapeSql = node.find("escapeSql")
escapeSql = escapeSql.text if escapeSql is not None else None
keyColumn = node.find("keyColumn")
keyColumn = keyColumn.text if keyColumn is not None else None
n_g = node.find("geometry")
geometry = JDBCVirtualTableGeometry(n_g.find("name"), n_g.find("type"), n_g.find("srid"))
| python | {
"resource": ""
} |
q255090 | md_entry | validation | def md_entry(node):
"""Extract metadata entries from an xml node"""
key = None
value = None
if 'key' in node.attrib:
key = node.attrib['key']
else:
key = None
if key in ['time', 'elevation'] or key.startswith('custom_dimension'):
value = | python | {
"resource": ""
} |
q255091 | DimensionInfo.resolution_millis | validation | def resolution_millis(self):
'''if set, get the value of resolution in milliseconds'''
if self.resolution is None or not isinstance(self.resolution, basestring):
| python | {
"resource": ""
} |
q255092 | MySQLBrowserResource._init | validation | def _init(self):
"""Read resource information into self._cache, for cached access.
See DAVResource._init()
"""
# TODO: recalc self.path from <self._file_path>, to fix correct file system case
# On windows this would lead to correct URLs
self.provider._count_get_resource_inst_init += 1
tableName, primKey = self.provider._split_path(self.path)
display_type = "Unknown"
displayTypeComment = ""
contentType = "text/html"
# _logger.debug("getInfoDict(%s), nc=%s" % (path, self.connectCount))
if tableName is None:
display_type = "Database"
elif primKey is None: # "database" and table name
display_type = "Database Table"
else:
contentType = "text/csv"
if primKey == "_ENTIRE_CONTENTS":
display_type = "Database Table Contents"
displayTypeComment = "CSV Representation of Table Contents"
else:
display_type = "Database Record"
displayTypeComment = "Attributes available as properties"
# Avoid calling | python | {
"resource": ""
} |
q255093 | as_DAVError | validation | def as_DAVError(e):
"""Convert any non-DAVError exception to HTTP_INTERNAL_ERROR."""
if isinstance(e, DAVError):
return e
elif isinstance(e, Exception):
# traceback.print_exc() | python | {
"resource": ""
} |
q255094 | DAVError.get_user_info | validation | def get_user_info(self):
"""Return readable string."""
if self.value in ERROR_DESCRIPTIONS:
s = "{}".format(ERROR_DESCRIPTIONS[self.value])
else:
s = "{}".format(self.value)
if self.context_info:
s += ": {}".format(self.context_info)
elif self.value in ERROR_RESPONSES:
| python | {
"resource": ""
} |
q255095 | VirtualResource.handle_delete | validation | def handle_delete(self):
"""Change semantic of DELETE to remove resource tags."""
# DELETE is only supported for the '/by_tag/' collection
if "/by_tag/" not in self.path:
| python | {
"resource": ""
} |
q255096 | VirtualResource.handle_copy | validation | def handle_copy(self, dest_path, depth_infinity):
"""Change semantic of COPY to add resource tags."""
# destPath must be '/by_tag/<tag>/<resname>'
if "/by_tag/" not in | python | {
"resource": ""
} |
q255097 | VirtualResource.handle_move | validation | def handle_move(self, dest_path):
"""Change semantic of MOVE to change resource tags."""
# path and destPath must be '/by_tag/<tag>/<resname>'
if "/by_tag/" not in self.path:
raise DAVError(HTTP_FORBIDDEN)
if "/by_tag/" not in dest_path:
raise DAVError(HTTP_FORBIDDEN)
catType, tag, _rest = util.save_split(self.path.strip("/"), "/", 2)
assert catType == "by_tag"
| python | {
"resource": ""
} |
q255098 | VirtualResourceProvider.get_resource_inst | validation | def get_resource_inst(self, path, environ):
"""Return _VirtualResource object for path.
path is expected to be
categoryType/category/name/artifact
for example:
'by_tag/cool/My doc 2/info.html'
See DAVProvider.get_resource_inst()
"""
| python | {
"resource": ""
} |
q255099 | WsgiDAVApp.add_provider | validation | def add_provider(self, share, provider, readonly=False):
"""Add a provider to the provider_map routing table."""
# Make sure share starts with, or is '/'
share = "/" + share.strip("/")
assert share not in self.provider_map
if compat.is_basestring(provider):
# Syntax:
# <mount_path>: <folder_path>
# We allow a simple string as 'provider'. In this case we interpret
# it as a file system root folder that is published.
provider = FilesystemProvider(provider, readonly)
elif type(provider) in (dict,):
if "provider" in provider:
# Syntax:
# <mount_path>: {"provider": <class_path>, "args": <pos_args>, "kwargs": <named_args}
prov_class = dynamic_import_class(provider["provider"])
provider = prov_class(
*provider.get("args", []), **provider.get("kwargs", {})
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.