text stringlengths 0 828 |
|---|
# TODO(TheDodd): match func call signature and docs. |
return wrapper" |
3849,"def check_auth(args, role=None): |
""""""Check the user authentication."""""" |
users = boto3.resource(""dynamodb"").Table(os.environ['people']) |
if not (args.get('email', None) and args.get('api_key', None)): |
mesg = ""Invalid request: `email` and `api_key` are required"" |
return {'success': False, 'message': mesg} |
user = users.get_item(Key={'email': args.get('email')}) |
if 'Item' not in user: |
return {'success': False, 'message': 'User does not exist.'} |
user = user['Item'] |
if user['api_key'] != args['api_key']: |
return {'success': False, 'message': 'API key was invalid.'} |
if role: |
if user['role'] not in role: |
mesg = 'User is not authorized to make this change.' |
return {'success': False, 'message': mesg} |
return {'success': True, 'message': None, 'user': user}" |
3850,"def lambda_handler(event, context): |
""""""Main handler."""""" |
auth = check_auth(event, role=[""admin""]) |
if not auth['success']: |
return auth |
table = boto3.resource(""dynamodb"").Table(os.environ['database']) |
results = table.scan() |
output = {'success': True, 'events': list(), 'eventsCount': 0} |
for item in results.get('Items', list()): |
output['events'].append(item) |
output['eventsCount'] = len(output['events']) |
return output" |
3851,"def get_theme_dir(): |
"""""" |
Returns path to directory containing this package's theme. |
This is designed to be used when setting the ``html_theme_path`` |
option within Sphinx's ``conf.py`` file. |
"""""" |
return os.path.abspath(os.path.join(os.path.dirname(__file__), ""theme""))" |
3852,"def create_discount_promotion(cls, discount_promotion, **kwargs): |
""""""Create DiscountPromotion |
Create a new DiscountPromotion |
This method makes a synchronous HTTP request by default. To make an |
asynchronous HTTP request, please pass async=True |
>>> thread = api.create_discount_promotion(discount_promotion, async=True) |
>>> result = thread.get() |
:param async bool |
:param DiscountPromotion discount_promotion: Attributes of discountPromotion to create (required) |
:return: DiscountPromotion |
If the method is called asynchronously, |
returns the request thread. |
"""""" |
kwargs['_return_http_data_only'] = True |
if kwargs.get('async'): |
return cls._create_discount_promotion_with_http_info(discount_promotion, **kwargs) |
else: |
(data) = cls._create_discount_promotion_with_http_info(discount_promotion, **kwargs) |
return data" |
3853,"def delete_discount_promotion_by_id(cls, discount_promotion_id, **kwargs): |
""""""Delete DiscountPromotion |
Delete an instance of DiscountPromotion by its ID. |
This method makes a synchronous HTTP request by default. To make an |
asynchronous HTTP request, please pass async=True |
>>> thread = api.delete_discount_promotion_by_id(discount_promotion_id, async=True) |
>>> result = thread.get() |
:param async bool |
:param str discount_promotion_id: ID of discountPromotion to delete. (required) |
:return: None |
If the method is called asynchronously, |
returns the request thread. |
"""""" |
kwargs['_return_http_data_only'] = True |
if kwargs.get('async'): |
return cls._delete_discount_promotion_by_id_with_http_info(discount_promotion_id, **kwargs) |
else: |
(data) = cls._delete_discount_promotion_by_id_with_http_info(discount_promotion_id, **kwargs) |
return data" |
3854,"def get_discount_promotion_by_id(cls, discount_promotion_id, **kwargs): |
""""""Find DiscountPromotion |
Return single instance of DiscountPromotion by its ID. |
This method makes a synchronous HTTP request by default. To make an |
asynchronous HTTP request, please pass async=True |
>>> thread = api.get_discount_promotion_by_id(discount_promotion_id, async=True) |
>>> result = thread.get() |
:param async bool |
:param str discount_promotion_id: ID of discountPromotion to return (required) |
:return: DiscountPromotion |
If the method is called asynchronously, |
returns the request thread. |
"""""" |
kwargs['_return_http_data_only'] = True |
if kwargs.get('async'): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.