desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Returns information about all available Trusted Advisor
checks, including name, ID, category, description, and
metadata. You must specify a language code; English ("en") and
Japanese ("ja") are currently supported. The response contains
a TrustedAdvisorCheckDescription for each check.
:type language: string
:param lan... | def describe_trusted_advisor_checks(self, language):
| params = {'language': language}
return self.make_request(action='DescribeTrustedAdvisorChecks', body=json.dumps(params))
|
'Requests a refresh of the Trusted Advisor check that has the
specified check ID. Check IDs can be obtained by calling
DescribeTrustedAdvisorChecks.
The response contains a RefreshTrustedAdvisorCheckResult
object, which contains these fields:
+ **Status.** The refresh status of the check: "none",
"enqueued", "processin... | def refresh_trusted_advisor_check(self, check_id):
| params = {'checkId': check_id}
return self.make_request(action='RefreshTrustedAdvisorCheck', body=json.dumps(params))
|
'Takes a `CaseId` and returns the initial state of the case
along with the state of the case after the call to ResolveCase
completed.
:type case_id: string
:param case_id: The AWS Support case ID requested or returned in the
call. The case ID is an alphanumeric string formatted as shown in
this example: case- 123456789... | def resolve_case(self, case_id=None):
| params = {}
if (case_id is not None):
params['caseId'] = case_id
return self.make_request(action='ResolveCase', body=json.dumps(params))
|
'The CancelJob operation cancels an unfinished job.
You can only cancel a job that has a status of `Submitted`. To
prevent a pipeline from starting to process a job while you\'re
getting the job identifier, use UpdatePipelineStatus to
temporarily pause the pipeline.
:type id: string
:param id: The identifier of the job... | def cancel_job(self, id=None):
| uri = '/2012-09-25/jobs/{0}'.format(id)
return self.make_request('DELETE', uri, expected_status=202)
|
'When you create a job, Elastic Transcoder returns JSON data
that includes the values that you specified plus information
about the job that is created.
If you have specified more than one output for your jobs (for
example, one output for the Kindle Fire and another output for
the Apple iPhone 4s), you currently must u... | def create_job(self, pipeline_id=None, input_name=None, output=None, outputs=None, output_key_prefix=None, playlists=None):
| uri = '/2012-09-25/jobs'
params = {}
if (pipeline_id is not None):
params['PipelineId'] = pipeline_id
if (input_name is not None):
params['Input'] = input_name
if (output is not None):
params['Output'] = output
if (outputs is not None):
params['Outputs'] = outputs... |
'The CreatePipeline operation creates a pipeline with settings
that you specify.
:type name: string
:param name: The name of the pipeline. We recommend that the name be
unique within the AWS account, but uniqueness is not enforced.
Constraints: Maximum 40 characters.
:type input_bucket: string
:param input_bucket: The ... | def create_pipeline(self, name=None, input_bucket=None, output_bucket=None, role=None, notifications=None, content_config=None, thumbnail_config=None):
| uri = '/2012-09-25/pipelines'
params = {}
if (name is not None):
params['Name'] = name
if (input_bucket is not None):
params['InputBucket'] = input_bucket
if (output_bucket is not None):
params['OutputBucket'] = output_bucket
if (role is not None):
params['Role'] ... |
'The CreatePreset operation creates a preset with settings that
you specify.
Elastic Transcoder checks the CreatePreset settings to ensure
that they meet Elastic Transcoder requirements and to
determine whether they comply with H.264 standards. If your
settings are not valid for Elastic Transcoder, Elastic
Transcoder r... | def create_preset(self, name=None, description=None, container=None, video=None, audio=None, thumbnails=None):
| uri = '/2012-09-25/presets'
params = {}
if (name is not None):
params['Name'] = name
if (description is not None):
params['Description'] = description
if (container is not None):
params['Container'] = container
if (video is not None):
params['Video'] = video
i... |
'The DeletePipeline operation removes a pipeline.
You can only delete a pipeline that has never been used or
that is not currently in use (doesn\'t contain any active
jobs). If the pipeline is currently in use, `DeletePipeline`
returns an error.
:type id: string
:param id: The identifier of the pipeline that you want t... | def delete_pipeline(self, id=None):
| uri = '/2012-09-25/pipelines/{0}'.format(id)
return self.make_request('DELETE', uri, expected_status=202)
|
'The DeletePreset operation removes a preset that you\'ve added
in an AWS region.
You can\'t delete the default presets that are included with
Elastic Transcoder.
:type id: string
:param id: The identifier of the preset for which you want to get
detailed information.'
| def delete_preset(self, id=None):
| uri = '/2012-09-25/presets/{0}'.format(id)
return self.make_request('DELETE', uri, expected_status=202)
|
'The ListJobsByPipeline operation gets a list of the jobs
currently in a pipeline.
Elastic Transcoder returns all of the jobs currently in the
specified pipeline. The response body contains one element for
each job that satisfies the search criteria.
:type pipeline_id: string
:param pipeline_id: The ID of the pipeline ... | def list_jobs_by_pipeline(self, pipeline_id=None, ascending=None, page_token=None):
| uri = '/2012-09-25/jobsByPipeline/{0}'.format(pipeline_id)
params = {}
if (pipeline_id is not None):
params['PipelineId'] = pipeline_id
if (ascending is not None):
params['Ascending'] = ascending
if (page_token is not None):
params['PageToken'] = page_token
return self.ma... |
'The ListJobsByStatus operation gets a list of jobs that have a
specified status. The response body contains one element for
each job that satisfies the search criteria.
:type status: string
:param status: To get information about all of the jobs associated with
the current AWS account that have a given status, specify... | def list_jobs_by_status(self, status=None, ascending=None, page_token=None):
| uri = '/2012-09-25/jobsByStatus/{0}'.format(status)
params = {}
if (status is not None):
params['Status'] = status
if (ascending is not None):
params['Ascending'] = ascending
if (page_token is not None):
params['PageToken'] = page_token
return self.make_request('GET', uri... |
'The ListPipelines operation gets a list of the pipelines
associated with the current AWS account.
:type ascending: string
:param ascending: To list pipelines in chronological order by the date
and time that they were created, enter `True`. To list pipelines in
reverse chronological order, enter `False`.
:type page_tok... | def list_pipelines(self, ascending=None, page_token=None):
| uri = '/2012-09-25/pipelines'.format()
params = {}
if (ascending is not None):
params['Ascending'] = ascending
if (page_token is not None):
params['PageToken'] = page_token
return self.make_request('GET', uri, expected_status=200, params=params)
|
'The ListPresets operation gets a list of the default presets
included with Elastic Transcoder and the presets that you\'ve
added in an AWS region.
:type ascending: string
:param ascending: To list presets in chronological order by the date
and time that they were created, enter `True`. To list presets in
reverse chron... | def list_presets(self, ascending=None, page_token=None):
| uri = '/2012-09-25/presets'.format()
params = {}
if (ascending is not None):
params['Ascending'] = ascending
if (page_token is not None):
params['PageToken'] = page_token
return self.make_request('GET', uri, expected_status=200, params=params)
|
'The ReadJob operation returns detailed information about a
job.
:type id: string
:param id: The identifier of the job for which you want to get detailed
information.'
| def read_job(self, id=None):
| uri = '/2012-09-25/jobs/{0}'.format(id)
return self.make_request('GET', uri, expected_status=200)
|
'The ReadPipeline operation gets detailed information about a
pipeline.
:type id: string
:param id: The identifier of the pipeline to read.'
| def read_pipeline(self, id=None):
| uri = '/2012-09-25/pipelines/{0}'.format(id)
return self.make_request('GET', uri, expected_status=200)
|
'The ReadPreset operation gets detailed information about a
preset.
:type id: string
:param id: The identifier of the preset for which you want to get
detailed information.'
| def read_preset(self, id=None):
| uri = '/2012-09-25/presets/{0}'.format(id)
return self.make_request('GET', uri, expected_status=200)
|
'The TestRole operation tests the IAM role used to create the
pipeline.
The `TestRole` action lets you determine whether the IAM role
you are using has sufficient permissions to let Elastic
Transcoder perform tasks associated with the transcoding
process. The action attempts to assume the specified IAM role,
checks rea... | def test_role(self, role=None, input_bucket=None, output_bucket=None, topics=None):
| uri = '/2012-09-25/roleTests'
params = {}
if (role is not None):
params['Role'] = role
if (input_bucket is not None):
params['InputBucket'] = input_bucket
if (output_bucket is not None):
params['OutputBucket'] = output_bucket
if (topics is not None):
params['Topic... |
'Use the `UpdatePipeline` operation to update settings for a
pipeline. When you change pipeline settings, your changes take
effect immediately. Jobs that you have already submitted and
that Elastic Transcoder has not started to process are
affected in addition to jobs that you submit after you change
settings.
:type id... | def update_pipeline(self, id, name=None, input_bucket=None, role=None, notifications=None, content_config=None, thumbnail_config=None):
| uri = '/2012-09-25/pipelines/{0}'.format(id)
params = {}
if (name is not None):
params['Name'] = name
if (input_bucket is not None):
params['InputBucket'] = input_bucket
if (role is not None):
params['Role'] = role
if (notifications is not None):
params['Notificat... |
'With the UpdatePipelineNotifications operation, you can update
Amazon Simple Notification Service (Amazon SNS) notifications
for a pipeline.
When you update notifications for a pipeline, Elastic
Transcoder returns the values that you specified in the
request.
:type id: string
:param id: The identifier of the pipeline ... | def update_pipeline_notifications(self, id=None, notifications=None):
| uri = '/2012-09-25/pipelines/{0}/notifications'.format(id)
params = {}
if (id is not None):
params['Id'] = id
if (notifications is not None):
params['Notifications'] = notifications
return self.make_request('POST', uri, expected_status=200, data=json.dumps(params))
|
'The UpdatePipelineStatus operation pauses or reactivates a
pipeline, so that the pipeline stops or restarts the
processing of jobs.
Changing the pipeline status is useful if you want to cancel
one or more jobs. You can\'t cancel jobs after Elastic
Transcoder has started processing them; if you pause the
pipeline to wh... | def update_pipeline_status(self, id=None, status=None):
| uri = '/2012-09-25/pipelines/{0}/status'.format(id)
params = {}
if (id is not None):
params['Id'] = id
if (status is not None):
params['Status'] = status
return self.make_request('POST', uri, expected_status=200, data=json.dumps(params))
|
':type value: file-like object
:param value: A file-like object containing the content
of the message. The actual content will be stored
in S3 and a link to the S3 object will be stored in
the message body.'
| def encode(self, value):
| (bucket_name, key_name) = self._get_bucket_key(self.s3_url)
if (bucket_name and key_name):
return self.s3_url
key_name = uuid.uuid4()
s3_conn = boto.connect_s3()
s3_bucket = s3_conn.get_bucket(bucket_name)
key = s3_bucket.new_key(key_name)
key.set_contents_from_file(value)
self.s... |
'Set the message class that should be used when instantiating
messages read from the queue. By default, the class
:class:`boto.sqs.message.Message` is used but this can be overriden
with any class that behaves like a message.
:type message_class: Message-like class
:param message_class: The new Message class'
| def set_message_class(self, message_class):
| self.message_class = message_class
|
'Retrieves attributes about this queue object and returns
them in an Attribute instance (subclass of a Dictionary).
:type attributes: string
:param attributes: String containing one of:
ApproximateNumberOfMessages,
ApproximateNumberOfMessagesNotVisible,
VisibilityTimeout,
CreatedTimestamp,
LastModifiedTimestamp,
Policy... | def get_attributes(self, attributes='All'):
| return self.connection.get_queue_attributes(self, attributes)
|
'Set a new value for an attribute of the Queue.
:type attribute: String
:param attribute: The name of the attribute you want to set.
:param value: The new value for the attribute must be:
* For `DelaySeconds` the value must be an integer number of
seconds from 0 to 900 (15 minutes).
>>> queue.set_attribute(\'DelaySecon... | def set_attribute(self, attribute, value):
| return self.connection.set_queue_attribute(self, attribute, value)
|
'Get the visibility timeout for the queue.
:rtype: int
:return: The number of seconds as an integer.'
| def get_timeout(self):
| a = self.get_attributes('VisibilityTimeout')
return int(a['VisibilityTimeout'])
|
'Set the visibility timeout for the queue.
:type visibility_timeout: int
:param visibility_timeout: The desired timeout in seconds'
| def set_timeout(self, visibility_timeout):
| retval = self.set_attribute('VisibilityTimeout', visibility_timeout)
if retval:
self.visibility_timeout = visibility_timeout
return retval
|
'Add a permission to a queue.
:type label: str or unicode
:param label: A unique identification of the permission you are setting.
Maximum of 80 characters ``[0-9a-zA-Z_-]``
Example, AliceSendMessage
:type aws_account_id: str or unicode
:param principal_id: The AWS account number of the principal who
will be given perm... | def add_permission(self, label, aws_account_id, action_name):
| return self.connection.add_permission(self, label, aws_account_id, action_name)
|
'Remove a permission from a queue.
:type label: str or unicode
:param label: The unique label associated with the permission
being removed.
:rtype: bool
:return: True if successful, False otherwise.'
| def remove_permission(self, label):
| return self.connection.remove_permission(self, label)
|
'Read a single message from the queue.
:type visibility_timeout: int
:param visibility_timeout: The timeout for this message in seconds
:type wait_time_seconds: int
:param wait_time_seconds: The duration (in seconds) for which the call
will wait for a message to arrive in the queue before returning.
If a message is ava... | def read(self, visibility_timeout=None, wait_time_seconds=None, message_attributes=None):
| rs = self.get_messages(1, visibility_timeout, wait_time_seconds=wait_time_seconds, message_attributes=message_attributes)
if (len(rs) == 1):
return rs[0]
else:
return None
|
'Add a single message to the queue.
:type message: Message
:param message: The message to be written to the queue
:rtype: :class:`boto.sqs.message.Message`
:return: The :class:`boto.sqs.message.Message` object that was written.'
| def write(self, message, delay_seconds=None):
| new_msg = self.connection.send_message(self, message.get_body_encoded(), delay_seconds=delay_seconds, message_attributes=message.message_attributes)
message.id = new_msg.id
message.md5 = new_msg.md5
return message
|
'Delivers up to 10 messages in a single request.
:type messages: List of lists.
:param messages: A list of lists or tuples. Each inner
tuple represents a single message to be written
and consists of and ID (string) that must be unique
within the list of messages, the message body itself
which can be a maximum of 64K i... | def write_batch(self, messages):
| return self.connection.send_message_batch(self, messages)
|
'Create new message of appropriate class.
:type body: message body
:param body: The body of the newly created message (optional).
:rtype: :class:`boto.sqs.message.Message`
:return: A new Message object'
| def new_message(self, body='', **kwargs):
| m = self.message_class(self, body, **kwargs)
m.queue = self
return m
|
'Get a variable number of messages.
:type num_messages: int
:param num_messages: The maximum number of messages to read from
the queue.
:type visibility_timeout: int
:param visibility_timeout: The VisibilityTimeout for the messages read.
:type attributes: str
:param attributes: The name of additional attribute to retur... | def get_messages(self, num_messages=1, visibility_timeout=None, attributes=None, wait_time_seconds=None, message_attributes=None):
| return self.connection.receive_message(self, number_messages=num_messages, visibility_timeout=visibility_timeout, attributes=attributes, wait_time_seconds=wait_time_seconds, message_attributes=message_attributes)
|
'Delete a message from the queue.
:type message: :class:`boto.sqs.message.Message`
:param message: The :class:`boto.sqs.message.Message` object to delete.
:rtype: bool
:return: True if successful, False otherwise'
| def delete_message(self, message):
| return self.connection.delete_message(self, message)
|
'Deletes a list of messages in a single request.
:type messages: List of :class:`boto.sqs.message.Message` objects.
:param messages: A list of message objects.'
| def delete_message_batch(self, messages):
| return self.connection.delete_message_batch(self, messages)
|
'A batch version of change_message_visibility that can act
on up to 10 messages at a time.
:type messages: List of tuples.
:param messages: A list of tuples where each tuple consists
of a :class:`boto.sqs.message.Message` object and an integer
that represents the new visibility timeout for that message.'
| def change_message_visibility_batch(self, messages):
| return self.connection.change_message_visibility_batch(self, messages)
|
'Delete the queue.'
| def delete(self):
| return self.connection.delete_queue(self)
|
'Purge all messages in the queue.'
| def purge(self):
| return self.connection.purge_queue(self)
|
'Deprecated utility function to remove all messages from a queue'
| def clear(self, page_size=10, vtimeout=10):
| return self.purge()
|
'Utility function to count the number of messages in a queue.
Note: This function now calls GetQueueAttributes to obtain
an \'approximate\' count of the number of messages in a queue.'
| def count(self, page_size=10, vtimeout=10):
| a = self.get_attributes('ApproximateNumberOfMessages')
return int(a['ApproximateNumberOfMessages'])
|
'Deprecated. This is the old \'count\' method that actually counts
the messages by reading them all. This gives an accurate count but
is very slow for queues with non-trivial number of messasges.
Instead, use get_attributes(\'ApproximateNumberOfMessages\') to take
advantage of the new SQS capability. This is retaine... | def count_slow(self, page_size=10, vtimeout=10):
| n = 0
l = self.get_messages(page_size, vtimeout)
while l:
for m in l:
n += 1
l = self.get_messages(page_size, vtimeout)
return n
|
'Utility function to dump the messages in a queue to a file
NOTE: Page size must be < 10 else SQS errors'
| def dump(self, file_name, page_size=10, vtimeout=10, sep='\n'):
| fp = open(file_name, 'wb')
n = 0
l = self.get_messages(page_size, vtimeout)
while l:
for m in l:
fp.write(m.get_body())
if sep:
fp.write(sep)
n += 1
l = self.get_messages(page_size, vtimeout)
fp.close()
return n
|
'Read all messages from the queue and persist them to file-like object.
Messages are written to the file and the \'sep\' string is written
in between messages. Messages are deleted from the queue after
being written to the file.
Returns the number of messages saved.'
| def save_to_file(self, fp, sep='\n'):
| n = 0
m = self.read()
while m:
n += 1
fp.write(m.get_body())
if sep:
fp.write(sep)
self.delete_message(m)
m = self.read()
return n
|
'Read all messages from the queue and persist them to local file.
Messages are written to the file and the \'sep\' string is written
in between messages. Messages are deleted from the queue after
being written to the file.
Returns the number of messages saved.'
| def save_to_filename(self, file_name, sep='\n'):
| fp = open(file_name, 'wb')
n = self.save_to_file(fp, sep)
fp.close()
return n
|
'Read all messages from the queue and persist them to S3.
Messages are stored in the S3 bucket using a naming scheme of::
<queue_id>/<message_id>
Messages are deleted from the queue after being saved to S3.
Returns the number of messages saved.'
| def save_to_s3(self, bucket):
| n = 0
m = self.read()
while m:
n += 1
key = bucket.new_key(('%s/%s' % (self.id, m.id)))
key.set_contents_from_string(m.get_body())
self.delete_message(m)
m = self.read()
return n
|
'Load messages previously saved to S3.'
| def load_from_s3(self, bucket, prefix=None):
| n = 0
if prefix:
prefix = ('%s/' % prefix)
else:
prefix = ('%s/' % self.id[1:])
rs = bucket.list(prefix=prefix)
for key in rs:
n += 1
m = self.new_message(key.get_contents_as_string())
self.write(m)
return n
|
'Utility function to load messages from a file-like object to a queue'
| def load_from_file(self, fp, sep='\n'):
| n = 0
body = ''
l = fp.readline()
while l:
if (l == sep):
m = Message(self, body)
self.write(m)
n += 1
print ('writing message %d' % n)
body = ''
else:
body = (body + l)
l = fp.readline()
return n
|
'Utility function to load messages from a local filename to a queue'
| def load_from_filename(self, file_name, sep='\n'):
| fp = open(file_name, 'rb')
n = self.load_from_file(fp, sep)
fp.close()
return n
|
'Create an SQS Queue.
:type queue_name: str or unicode
:param queue_name: The name of the new queue. Names are
scoped to an account and need to be unique within that
account. Calling this method on an existing queue name
will not return an error from SQS unless the value for
visibility_timeout is different than the v... | def create_queue(self, queue_name, visibility_timeout=None):
| params = {'QueueName': queue_name}
if visibility_timeout:
params['Attribute.1.Name'] = 'VisibilityTimeout'
params['Attribute.1.Value'] = int(visibility_timeout)
return self.get_object('CreateQueue', params, Queue)
|
'Delete an SQS Queue.
:type queue: A Queue object
:param queue: The SQS queue to be deleted
:type force_deletion: Boolean
:param force_deletion: A deprecated parameter that is no longer used by
SQS\'s API.
:rtype: bool
:return: True if the command succeeded, False otherwise'
| def delete_queue(self, queue, force_deletion=False):
| return self.get_status('DeleteQueue', None, queue.id)
|
'Purge all messages in an SQS Queue.
:type queue: A Queue object
:param queue: The SQS queue to be purged
:rtype: bool
:return: True if the command succeeded, False otherwise'
| def purge_queue(self, queue):
| return self.get_status('PurgeQueue', None, queue.id)
|
'Gets one or all attributes of a Queue
:type queue: A Queue object
:param queue: The SQS queue to get attributes for
:type attribute: str
:param attribute: The specific attribute requested. If not
supplied, the default is to return all attributes. Valid
attributes are:
* All
* ApproximateNumberOfMessages
* Approximat... | def get_queue_attributes(self, queue, attribute='All'):
| params = {'AttributeName': attribute}
return self.get_object('GetQueueAttributes', params, Attributes, queue.id)
|
'Set a new value for an attribute of a Queue.
:type queue: A Queue object
:param queue: The SQS queue to get attributes for
:type attribute: String
:param attribute: The name of the attribute you want to set.
:param value: The new value for the attribute must be:
* For `DelaySeconds` the value must be an integer number... | def set_queue_attribute(self, queue, attribute, value):
| params = {'Attribute.Name': attribute, 'Attribute.Value': value}
return self.get_status('SetQueueAttributes', params, queue.id)
|
'Read messages from an SQS Queue.
:type queue: A Queue object
:param queue: The Queue from which messages are read.
:type number_messages: int
:param number_messages: The maximum number of messages to read
(default=1)
:type visibility_timeout: int
:param visibility_timeout: The number of seconds the message should
rema... | def receive_message(self, queue, number_messages=1, visibility_timeout=None, attributes=None, wait_time_seconds=None, message_attributes=None):
| params = {'MaxNumberOfMessages': number_messages}
if (visibility_timeout is not None):
params['VisibilityTimeout'] = visibility_timeout
if (attributes is not None):
self.build_list_params(params, attributes, 'AttributeName')
if (wait_time_seconds is not None):
params['WaitTimeSec... |
'Delete a message from a queue.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type message: A :class:`boto.sqs.message.Message` object
:param message: The Message to be deleted
:rtype: bool
:return: True if successful, False otherwise.'
| def delete_message(self, queue, message):
| params = {'ReceiptHandle': message.receipt_handle}
return self.get_status('DeleteMessage', params, queue.id)
|
'Deletes a list of messages from a queue in a single request.
:type queue: A :class:`boto.sqs.queue.Queue` object.
:param queue: The Queue to which the messages will be written.
:type messages: List of :class:`boto.sqs.message.Message` objects.
:param messages: A list of message objects.'
| def delete_message_batch(self, queue, messages):
| params = {}
for (i, msg) in enumerate(messages):
prefix = 'DeleteMessageBatchRequestEntry'
p_name = ('%s.%i.Id' % (prefix, (i + 1)))
params[p_name] = msg.id
p_name = ('%s.%i.ReceiptHandle' % (prefix, (i + 1)))
params[p_name] = msg.receipt_handle
return self.get_object... |
'Delete a message from a queue, given a receipt handle.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type receipt_handle: str
:param receipt_handle: The receipt handle for the message
:rtype: bool
:return: True if successful, False otherwise.'
| def delete_message_from_handle(self, queue, receipt_handle):
| params = {'ReceiptHandle': receipt_handle}
return self.get_status('DeleteMessage', params, queue.id)
|
'Send a new message to the queue.
:type queue: A :class:`boto.sqs.queue.Queue` object.
:param queue: The Queue to which the messages will be written.
:type message_content: string
:param message_content: The body of the message
:type delay_seconds: int
:param delay_seconds: Number of seconds (0 - 900) to delay this
mes... | def send_message(self, queue, message_content, delay_seconds=None, message_attributes=None):
| params = {'MessageBody': message_content}
if delay_seconds:
params['DelaySeconds'] = int(delay_seconds)
if (message_attributes is not None):
keys = sorted(message_attributes.keys())
for (i, name) in enumerate(keys, start=1):
attribute = message_attributes[name]
... |
'Delivers up to 10 messages to a queue in a single request.
:type queue: A :class:`boto.sqs.queue.Queue` object.
:param queue: The Queue to which the messages will be written.
:type messages: List of lists.
:param messages: A list of lists or tuples. Each inner
tuple represents a single message to be written
and consi... | def send_message_batch(self, queue, messages):
| params = {}
for (i, msg) in enumerate(messages):
base = ('SendMessageBatchRequestEntry.%i' % (i + 1))
params[('%s.Id' % base)] = msg[0]
params[('%s.MessageBody' % base)] = msg[1]
params[('%s.DelaySeconds' % base)] = msg[2]
if (len(msg) > 3):
base += '.MessageA... |
'Extends the read lock timeout for the specified message from
the specified queue to the specified value.
:type queue: A :class:`boto.sqs.queue.Queue` object
:param queue: The Queue from which messages are read.
:type receipt_handle: str
:param receipt_handle: The receipt handle associated with the message
whose visibi... | def change_message_visibility(self, queue, receipt_handle, visibility_timeout):
| params = {'ReceiptHandle': receipt_handle, 'VisibilityTimeout': visibility_timeout}
return self.get_status('ChangeMessageVisibility', params, queue.id)
|
'A batch version of change_message_visibility that can act
on up to 10 messages at a time.
:type queue: A :class:`boto.sqs.queue.Queue` object.
:param queue: The Queue to which the messages will be written.
:type messages: List of tuples.
:param messages: A list of tuples where each tuple consists
of a :class:`boto.sqs... | def change_message_visibility_batch(self, queue, messages):
| params = {}
for (i, t) in enumerate(messages):
prefix = 'ChangeMessageVisibilityBatchRequestEntry'
p_name = ('%s.%i.Id' % (prefix, (i + 1)))
params[p_name] = t[0].id
p_name = ('%s.%i.ReceiptHandle' % (prefix, (i + 1)))
params[p_name] = t[0].receipt_handle
p_name =... |
'Retrieves all queues.
:keyword str prefix: Optionally, only return queues that start with
this value.
:rtype: list
:returns: A list of :py:class:`boto.sqs.queue.Queue` instances.'
| def get_all_queues(self, prefix=''):
| params = {}
if prefix:
params['QueueNamePrefix'] = prefix
return self.get_list('ListQueues', params, [('QueueUrl', Queue)])
|
'Retrieves the queue with the given name, or ``None`` if no match
was found.
:param str queue_name: The name of the queue to retrieve.
:param str owner_acct_id: Optionally, the AWS account ID of the account that created the queue.
:rtype: :py:class:`boto.sqs.queue.Queue` or ``None``
:returns: The requested queue, or ``... | def get_queue(self, queue_name, owner_acct_id=None):
| params = {'QueueName': queue_name}
if owner_acct_id:
params['QueueOwnerAWSAccountId'] = owner_acct_id
try:
return self.get_object('GetQueueUrl', params, Queue)
except SQSError:
return None
|
'Retrieves the dead letter source queues for a given queue.
:type queue: A :class:`boto.sqs.queue.Queue` object.
:param queue: The queue for which to get DL source queues
:rtype: list
:returns: A list of :py:class:`boto.sqs.queue.Queue` instances.'
| def get_dead_letter_source_queues(self, queue):
| params = {'QueueUrl': queue.url}
return self.get_list('ListDeadLetterSourceQueues', params, [('QueueUrl', Queue)])
|
'Add a permission to a queue.
:type queue: :class:`boto.sqs.queue.Queue`
:param queue: The queue object
:type label: str or unicode
:param label: A unique identification of the permission you are setting.
Maximum of 80 characters ``[0-9a-zA-Z_-]``
Example, AliceSendMessage
:type aws_account_id: str or unicode
:param pr... | def add_permission(self, queue, label, aws_account_id, action_name):
| params = {'Label': label, 'AWSAccountId': aws_account_id, 'ActionName': action_name}
return self.get_status('AddPermission', params, queue.id)
|
'Remove a permission from a queue.
:type queue: :class:`boto.sqs.queue.Queue`
:param queue: The queue object
:type label: str or unicode
:param label: The unique label associated with the permission
being removed.
:rtype: bool
:return: True if successful, False otherwise.'
| def remove_permission(self, queue, label):
| params = {'Label': label}
return self.get_status('RemovePermission', params, queue.id)
|
'Transform body object into serialized byte array format.'
| def encode(self, value):
| return value
|
'Transform seralized byte array into any object.'
| def decode(self, value):
| return value
|
'Override the current body for this object, using decoded format.'
| def set_body(self, body):
| self._body = body
|
'This method is really a semi-private method used by the Queue.write
method when writing the contents of the message to SQS.
You probably shouldn\'t need to call this method in the normal course of events.'
| def get_body_encoded(self):
| return self.encode(self.get_body())
|
'Utility method to handle calls to ECS and parsing of responses.'
| def get_response(self, action, params, page=0, itemSet=None):
| params['Service'] = 'AWSECommerceService'
params['Operation'] = action
if page:
params['ItemPage'] = page
response = self.make_request(None, params, '/onca/xml')
body = response.read().decode('utf-8')
boto.log.debug(body)
if (response.status != 200):
boto.log.error(('%s %s... |
'Returns items that satisfy the search criteria, including one or more search
indices.
For a full list of search terms,
:see: http://docs.amazonwebservices.com/AWSECommerceService/2010-09-01/DG/index.html?ItemSearch.html'
| def item_search(self, search_index, **params):
| params['SearchIndex'] = search_index
return self.get_response('ItemSearch', params)
|
'Returns items that satisfy the lookup query.
For a full list of parameters, see:
http://s3.amazonaws.com/awsdocs/Associates/2011-08-01/prod-adv-api-dg-2011-08-01.pdf'
| def item_lookup(self, **params):
| return self.get_response('ItemLookup', params)
|
'Initialize this Item'
| def __init__(self, connection=None, nodename=None):
| self._connection = connection
self._nodename = nodename
self._nodepath = []
self._curobj = None
self._xml = StringIO()
|
'Initialize this Item'
| def __init__(self, connection=None):
| ResponseGroup.__init__(self, connection, 'Item')
|
'Special paging functionality'
| def __next__(self):
| if (self.iter is None):
self.iter = iter(self.objs)
try:
return next(self.iter)
except StopIteration:
self.iter = None
self.objs = []
if (int(self.page) < int(self.total_pages)):
self.page += 1
self._connection.get_response(self.action, self.pa... |
'Override to first fetch everything'
| def to_xml(self):
| for item in self:
pass
return ResponseGroup.to_xml(self)
|
''
| def get_account_balance(self):
| params = {}
return self._process_request('GetAccountBalance', params, [('AvailableBalance', Price), ('OnHoldBalance', Price)])
|
'Register a new HIT Type
title, description are strings
reward is a Price object
duration can be a timedelta, or an object castable to an int'
| def register_hit_type(self, title, description, reward, duration, keywords=None, approval_delay=None, qual_req=None):
| params = dict(Title=title, Description=description, AssignmentDurationInSeconds=self.duration_as_seconds(duration))
params.update(MTurkConnection.get_price_as_price(reward).get_as_params('Reward'))
if keywords:
params['Keywords'] = self.get_keywords_as_string(keywords)
if (approval_delay is not ... |
'Performs a SetHITTypeNotification operation to set email
notification for a specified HIT type'
| def set_email_notification(self, hit_type, email, event_types=None):
| return self._set_notification(hit_type, 'Email', email, 'SetHITTypeNotification', event_types)
|
'Performs a SetHITTypeNotification operation to set REST notification
for a specified HIT type'
| def set_rest_notification(self, hit_type, url, event_types=None):
| return self._set_notification(hit_type, 'REST', url, 'SetHITTypeNotification', event_types)
|
'Performs a SetHITTypeNotification operation so set SQS notification
for a specified HIT type. Queue URL is of form:
https://queue.amazonaws.com/<CUSTOMER_ID>/<QUEUE_NAME> and can be
found when looking at the details for a Queue in the AWS Console'
| def set_sqs_notification(self, hit_type, queue_url, event_types=None):
| return self._set_notification(hit_type, 'SQS', queue_url, 'SetHITTypeNotification', event_types)
|
'Performs a SendTestEventNotification operation with REST notification
for a specified HIT type'
| def send_test_event_notification(self, hit_type, url, event_types=None, test_event_type='Ping'):
| return self._set_notification(hit_type, 'REST', url, 'SendTestEventNotification', event_types, test_event_type)
|
'Common operation to set notification or send a test event
notification for a specified HIT type'
| def _set_notification(self, hit_type, transport, destination, request_type, event_types=None, test_event_type=None):
| params = {'HITTypeId': hit_type}
notification_params = {'Destination': destination, 'Transport': transport, 'Version': boto.mturk.notification.NotificationMessage.NOTIFICATION_VERSION, 'Active': True}
if event_types:
self.build_list_params(notification_params, event_types, 'EventType')
notificat... |
'Creates a new HIT.
Returns a ResultSet
See: http://docs.amazonwebservices.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_CreateHITOperation.html'
| def create_hit(self, hit_type=None, question=None, hit_layout=None, lifetime=datetime.timedelta(days=7), max_assignments=1, title=None, description=None, keywords=None, reward=None, duration=datetime.timedelta(days=7), approval_delay=None, annotation=None, questions=None, qualifications=None, layout_params=None, respon... | params = {'LifetimeInSeconds': self.duration_as_seconds(lifetime), 'MaxAssignments': max_assignments}
neither = ((question is None) and (questions is None))
if (hit_layout is None):
both = ((question is not None) and (questions is not None))
if (neither or both):
raise ValueError... |
'Change the HIT type of an existing HIT. Note that the reward associated
with the new HIT type must match the reward of the current HIT type in
order for the operation to be valid.
:type hit_id: str
:type hit_type: str'
| def change_hit_type_of_hit(self, hit_id, hit_type):
| params = {'HITId': hit_id, 'HITTypeId': hit_type}
return self._process_request('ChangeHITTypeOfHIT', params)
|
'Retrieve the HITs that have a status of Reviewable, or HITs that
have a status of Reviewing, and that belong to the Requester
calling the operation.'
| def get_reviewable_hits(self, hit_type=None, status='Reviewable', sort_by='Expiration', sort_direction='Ascending', page_size=10, page_number=1):
| params = {'Status': status, 'SortProperty': sort_by, 'SortDirection': sort_direction, 'PageSize': page_size, 'PageNumber': page_number}
if (hit_type is not None):
params.update({'HITTypeId': hit_type})
return self._process_request('GetReviewableHITs', params, [('HIT', HIT)])
|
'Given a page size (records per page) and a total number of
records, return the page numbers to be retrieved.'
| @staticmethod
def _get_pages(page_size, total_records):
| pages = ((total_records / page_size) + bool((total_records % page_size)))
return list(range(1, (pages + 1)))
|
'Return all of a Requester\'s HITs
Despite what search_hits says, it does not return all hits, but
instead returns a page of hits. This method will pull the hits
from the server 100 at a time, but will yield the results
iteratively, so subsequent requests are made on demand.'
| def get_all_hits(self):
| page_size = 100
search_rs = self.search_hits(page_size=page_size)
total_records = int(search_rs.TotalNumResults)
get_page_hits = (lambda page: self.search_hits(page_size=page_size, page_number=page))
page_nums = self._get_pages(page_size, total_records)
hit_sets = itertools.imap(get_page_hits, p... |
'Return a page of a Requester\'s HITs, on behalf of the Requester.
The operation returns HITs of any status, except for HITs that
have been disposed with the DisposeHIT operation.
Note:
The SearchHITs operation does not accept any search parameters
that filter the results.'
| def search_hits(self, sort_by='CreationTime', sort_direction='Ascending', page_size=10, page_number=1, response_groups=None):
| params = {'SortProperty': sort_by, 'SortDirection': sort_direction, 'PageSize': page_size, 'PageNumber': page_number}
if response_groups:
self.build_list_params(params, response_groups, 'ResponseGroup')
return self._process_request('SearchHITs', params, [('HIT', HIT)])
|
'Retrieves an assignment using the assignment\'s ID. Requesters can only
retrieve their own assignments, and only assignments whose related HIT
has not been disposed.
The returned ResultSet will have the following attributes:
Request
This element is present only if the Request ResponseGroup
is specified.
Assignment
The... | def get_assignment(self, assignment_id, response_groups=None):
| params = {'AssignmentId': assignment_id}
if response_groups:
self.build_list_params(params, response_groups, 'ResponseGroup')
return self._process_request('GetAssignment', params, [('Assignment', Assignment), ('HIT', HIT)])
|
'Retrieves completed assignments for a HIT.
Use this operation to retrieve the results for a HIT.
The returned ResultSet will have the following attributes:
NumResults
The number of assignments on the page in the filtered results
list, equivalent to the number of assignments being returned
by this call.
A non-negative ... | def get_assignments(self, hit_id, status=None, sort_by='SubmitTime', sort_direction='Ascending', page_size=10, page_number=1, response_groups=None):
| params = {'HITId': hit_id, 'SortProperty': sort_by, 'SortDirection': sort_direction, 'PageSize': page_size, 'PageNumber': page_number}
if (status is not None):
params['AssignmentStatus'] = status
if response_groups:
self.build_list_params(params, response_groups, 'ResponseGroup')
return ... |
''
| def approve_assignment(self, assignment_id, feedback=None):
| params = {'AssignmentId': assignment_id}
if feedback:
params['RequesterFeedback'] = feedback
return self._process_request('ApproveAssignment', params)
|
''
| def reject_assignment(self, assignment_id, feedback=None):
| params = {'AssignmentId': assignment_id}
if feedback:
params['RequesterFeedback'] = feedback
return self._process_request('RejectAssignment', params)
|
''
| def approve_rejected_assignment(self, assignment_id, feedback=None):
| params = {'AssignmentId': assignment_id}
if feedback:
params['RequesterFeedback'] = feedback
return self._process_request('ApproveRejectedAssignment', params)
|
'Generates and returns a temporary URL to an uploaded file. The
temporary URL is used to retrieve the file as an answer to a
FileUploadAnswer question, it is valid for 60 seconds.
Will have a FileUploadURL attribute as per the API Reference.'
| def get_file_upload_url(self, assignment_id, question_identifier):
| params = {'AssignmentId': assignment_id, 'QuestionIdentifier': question_identifier}
return self._process_request('GetFileUploadURL', params, [('FileUploadURL', FileUploadURL)])
|
''
| def get_hit(self, hit_id, response_groups=None):
| params = {'HITId': hit_id}
if response_groups:
self.build_list_params(params, response_groups, 'ResponseGroup')
return self._process_request('GetHIT', params, [('HIT', HIT)])
|
'Update a HIT with a status of Reviewable to have a status of Reviewing,
or reverts a Reviewing HIT back to the Reviewable status.
Only HITs with a status of Reviewable can be updated with a status of
Reviewing. Similarly, only Reviewing HITs can be reverted back to a
status of Reviewable.'
| def set_reviewing(self, hit_id, revert=None):
| params = {'HITId': hit_id}
if revert:
params['Revert'] = revert
return self._process_request('SetHITAsReviewing', params)
|
'Remove a HIT from the Mechanical Turk marketplace, approves all
submitted assignments that have not already been approved or rejected,
and disposes of the HIT and all assignment data.
Assignments for the HIT that have already been submitted, but not yet
approved or rejected, will be automatically approved. Assignments... | def disable_hit(self, hit_id, response_groups=None):
| params = {'HITId': hit_id}
if response_groups:
self.build_list_params(params, response_groups, 'ResponseGroup')
return self._process_request('DisableHIT', params)
|
'Dispose of a HIT that is no longer needed.
Only HITs in the "reviewable" state, with all submitted
assignments approved or rejected, can be disposed. A Requester
can call GetReviewableHITs to determine which HITs are
reviewable, then call GetAssignmentsForHIT to retrieve the
assignments. Disposing of a HIT removes th... | def dispose_hit(self, hit_id):
| params = {'HITId': hit_id}
return self._process_request('DisposeHIT', params)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.