text_prompt stringlengths 157 13.1k | code_prompt stringlengths 7 19.8k ⌀ |
|---|---|
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def to_s3_uri(code_dict):
"""Constructs a S3 URI string from given code dictionary :param dict code_dict: Dictionary containing Lambda function Code S3 location ... |
try:
uri = "s3://{bucket}/{key}".format(bucket=code_dict["S3Bucket"], key=code_dict["S3Key"])
version = code_dict.get("S3ObjectVersion", None)
except (TypeError, AttributeError):
raise TypeError("Code location should be a dictionary")
if version:
uri += "?versionId=" + ver... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def construct_s3_location_object(location_uri, logical_id, property_name):
"""Constructs a Lambda `Code` or `Content` property, from the SAM `CodeUri` or `Conten... |
if isinstance(location_uri, dict):
if not location_uri.get("Bucket") or not location_uri.get("Key"):
# location_uri is a dictionary but does not contain Bucket or Key property
raise InvalidResourceException(logical_id,
"'{}' requires Bucket... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _get_policies(self, resource_properties):
""" Returns a list of policies from the resource properties. This method knows how to interpret and handle polymorp... |
policies = None
if self._contains_policies(resource_properties):
policies = resource_properties[self.POLICIES_PROPERTY_NAME]
if not policies:
# Policies is None or empty
return []
if not isinstance(policies, list):
# Just a single entr... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _contains_policies(self, resource_properties):
""" Is there policies data in this resource? :param dict resource_properties: Properties of the resource :retu... |
return resource_properties is not None \
and isinstance(resource_properties, dict) \
and self.POLICIES_PROPERTY_NAME in resource_properties |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _get_type(self, policy):
""" Returns the type of the given policy :param string or dict policy: Policy data :return PolicyTypes: Type of the given policy. No... |
# Must handle intrinsic functions. Policy could be a primitive type or an intrinsic function
# Managed policies are either string or an intrinsic function that resolves to a string
if isinstance(policy, string_types) or is_instrinsic(policy):
return PolicyTypes.MANAGED_POLICY
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _is_policy_template(self, policy):
""" Is the given policy data a policy template? Policy templates is a dictionary with one key which is the name of the tem... |
return self._policy_template_processor is not None and \
isinstance(policy, dict) and \
len(policy) == 1 and \
self._policy_template_processor.has(list(policy.keys())[0]) is True |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_thing_shadow(self, **kwargs):
r""" Call shadow lambda to obtain current shadow state. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The na... |
thing_name = self._get_required_parameter('thingName', **kwargs)
payload = b''
return self._shadow_op('get', thing_name, payload) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def update_thing_shadow(self, **kwargs):
r""" Updates the thing shadow for the specified thing. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The ... |
thing_name = self._get_required_parameter('thingName', **kwargs)
payload = self._get_required_parameter('payload', **kwargs)
return self._shadow_op('update', thing_name, payload) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def delete_thing_shadow(self, **kwargs):
r""" Deletes the thing shadow for the specified thing. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The ... |
thing_name = self._get_required_parameter('thingName', **kwargs)
payload = b''
return self._shadow_op('delete', thing_name, payload) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def publish(self, **kwargs):
r""" Publishes state information. :Keyword Arguments: * *topic* (``string``) -- [REQUIRED] The name of the MQTT topic. * *payload* (... |
topic = self._get_required_parameter('topic', **kwargs)
# payload is an optional parameter
payload = kwargs.get('payload', b'')
function_arn = ROUTER_FUNCTION_ARN
client_context = {
'custom': {
'source': MY_FUNCTION_ARN,
'subject': ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def merge(self, resource_type, resource_properties):
""" Adds global properties to the resource, if necessary. This method is a no-op if there are no global prop... |
if resource_type not in self.template_globals:
# Nothing to do. Return the template unmodified
return resource_properties
global_props = self.template_globals[resource_type]
return global_props.merge(resource_properties) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _parse(self, globals_dict):
""" Takes a SAM template as input and parses the Globals section :param globals_dict: Dictionary representation of the Globals se... |
globals = {}
if not isinstance(globals_dict, dict):
raise InvalidGlobalsSectionException(self._KEYWORD,
"It must be a non-empty dictionary".format(self._KEYWORD))
for section_name, properties in globals_dict.items():
re... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _do_merge(self, global_value, local_value):
""" Actually perform the merge operation for the given inputs. This method is used as part of the recursion. Ther... |
token_global = self._token_of(global_value)
token_local = self._token_of(local_value)
# The following statements codify the rules explained in the doctring above
if token_global != token_local:
return self._prefer_local(global_value, local_value)
elif self.TOKEN.P... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _merge_dict(self, global_dict, local_dict):
""" Merges the two dictionaries together :param global_dict: Global dictionary to be merged :param local_dict: Lo... |
# Local has higher priority than global. So iterate over local dict and merge into global if keys are overridden
global_dict = global_dict.copy()
for key in local_dict.keys():
if key in global_dict:
# Both local & global contains the same key. Let's do a merge.
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _token_of(self, input):
""" Returns the token type of the input. :param input: Input whose type is to be determined :return TOKENS: Token type of the input "... |
if isinstance(input, dict):
# Intrinsic functions are always dicts
if is_intrinsics(input):
# Intrinsic functions are handled *exactly* like a primitive type because
# they resolve to a primitive type when creating a stack with CloudFormation
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def validate(template_dict, schema=None):
""" Is this a valid SAM template dictionary :param dict template_dict: Data to be validated :param dict schema: Optiona... |
if not schema:
schema = SamTemplateValidator._read_schema()
validation_errors = ""
try:
jsonschema.validate(template_dict, schema)
except ValidationError as ex:
# Stringifying the exception will give us useful error message
validation_e... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def generate_car_price(location, days, age, car_type):
""" Generates a number within a reasonable range that might be expected for a flight. The price is fixed f... |
car_types = ['economy', 'standard', 'midsize', 'full size', 'minivan', 'luxury']
base_location_cost = 0
for i in range(len(location)):
base_location_cost += ord(location.lower()[i]) - 97
age_multiplier = 1.10 if age < 25 else 1
# Select economy is car_type is not found
if car_type not... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def generate_hotel_price(location, nights, room_type):
""" Generates a number within a reasonable range that might be expected for a hotel. The price is fixed fo... |
room_types = ['queen', 'king', 'deluxe']
cost_of_living = 0
for i in range(len(location)):
cost_of_living += ord(location.lower()[i]) - 97
return nights * (100 + cost_of_living + (100 + room_types.index(room_type.lower()))) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def book_hotel(intent_request):
""" Performs dialog management and fulfillment for booking a hotel. Beyond fulfillment, the implementation for this intent demons... |
location = try_ex(lambda: intent_request['currentIntent']['slots']['Location'])
checkin_date = try_ex(lambda: intent_request['currentIntent']['slots']['CheckInDate'])
nights = safe_int(try_ex(lambda: intent_request['currentIntent']['slots']['Nights']))
room_type = try_ex(lambda: intent_request['curre... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def to_cloudformation(self, **kwargs):
"""Returns the Lambda EventSourceMapping to which this pull event corresponds. Adds the appropriate managed policy to the ... |
function = kwargs.get('function')
if not function:
raise TypeError("Missing required keyword argument: function")
resources = []
lambda_eventsourcemapping = LambdaEventSourceMapping(self.logical_id)
resources.append(lambda_eventsourcemapping)
try:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _link_policy(self, role):
"""If this source triggers a Lambda function whose execution role is auto-generated by SAM, add the appropriate managed policy to t... |
policy_arn = self.get_policy_arn()
if role is not None and policy_arn not in role.ManagedPolicyArns:
role.ManagedPolicyArns.append(policy_arn) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_default_parameter_values(self, sam_template):
""" Method to read default values for template parameters and merge with user supplied values. Example: If ... |
parameter_definition = sam_template.get("Parameters", None)
if not parameter_definition or not isinstance(parameter_definition, dict):
return self.parameter_values
for param_name, value in parameter_definition.items():
if param_name not in self.parameter_values and isi... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add(self, logical_id, deployment_preference_dict):
""" Add this deployment preference to the collection :raise ValueError if an existing logical id already e... |
if logical_id in self._resource_preferences:
raise ValueError("logical_id {logical_id} previously added to this deployment_preference_collection".format(
logical_id=logical_id))
self._resource_preferences[logical_id] = DeploymentPreference.from_dict(logical_id, deployment_p... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_welcome_response():
""" If we wanted to initialize the session to have some attributes we could add those here """ |
session_attributes = {}
card_title = "Welcome"
speech_output = "Welcome to the Alexa Skills Kit sample. " \
"Please tell me your favorite color by saying, " \
"my favorite color is red"
# If the user either does not reply to the welcome message or says something... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def set_color_in_session(intent, session):
""" Sets the color in the session and prepares the speech to reply to the user. """ |
card_title = intent['name']
session_attributes = {}
should_end_session = False
if 'Color' in intent['slots']:
favorite_color = intent['slots']['Color']['value']
session_attributes = create_favorite_color_attributes(favorite_color)
speech_output = "I now know your favorite colo... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def on_intent(intent_request, session):
""" Called when the user specifies an intent for this skill """ |
print("on_intent requestId=" + intent_request['requestId'] +
", sessionId=" + session['sessionId'])
intent = intent_request['intent']
intent_name = intent_request['intent']['name']
# Dispatch to your skill's intent handlers
if intent_name == "MyColorIsIntent":
return set_color_... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_hash(self, length=HASH_LENGTH):
""" Generate and return a hash of data that can be used as suffix of logicalId :return: Hash of data if it was present :r... |
data_hash = ""
if not self.data_str:
return data_hash
encoded_data_str = self.data_str
if sys.version_info.major == 2:
# In Py2, only unicode needs to be encoded.
if isinstance(self.data_str, unicode):
encoded_data_str = self.data_st... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _stringify(self, data):
""" Stable, platform & language-independent stringification of a data with basic Python type. We use JSON to dump a string instead of... |
if isinstance(data, string_types):
return data
# Get the most compact dictionary (separators) and sort the keys recursively to get a stable output
return json.dumps(data, separators=(',', ':'), sort_keys=True) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add(self, logical_id, property, value):
""" Add the information that resource with given `logical_id` supports the given `property`, and that a reference to ... |
if not logical_id or not property:
raise ValueError("LogicalId and property must be a non-empty string")
if not value or not isinstance(value, string_types):
raise ValueError("Property value must be a non-empty string")
if logical_id not in self._refs:
sel... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def encrypt(key, message):
'''encrypt leverages KMS encrypt and base64-encode encrypted blob
More info on KMS encrypt API:
https://docs.aws.amazon.com/kms/latest/APIReference/API_encrypt.html
'''
try:
ret = kms.encrypt(KeyId=key, Plaintext=message)
encrypted_data = base64.en... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_tag_list(resource_tag_dict):
""" Transforms the SAM defined Tags into the form CloudFormation is expecting. SAM Example: ``` Tags: TagKey: TagValue ``` C... |
tag_list = []
if resource_tag_dict is None:
return tag_list
for tag_key, tag_value in resource_tag_dict.items():
tag = {_KEY: tag_key, _VALUE: tag_value if tag_value else ""}
tag_list.append(tag)
return tag_list |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_partition_name(cls, region=None):
""" Gets the name of the partition given the region name. If region name is not provided, this method will use Boto3 to... |
if region is None:
# Use Boto3 to get the region where code is running. This uses Boto's regular region resolution
# mechanism, starting from AWS_DEFAULT_REGION environment variable.
region = boto3.session.Session().region_name
region_string = region.lower()
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def has_path(self, path, method=None):
""" Returns True if this Swagger has the given path and optional method :param string path: Path name :param string method... |
method = self._normalize_method_name(method)
path_dict = self.get_path(path)
path_dict_exists = path_dict is not None
if method:
return path_dict_exists and method in path_dict
return path_dict_exists |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def method_has_integration(self, method):
""" Returns true if the given method contains a valid method definition. This uses the get_method_contents function to ... |
for method_definition in self.get_method_contents(method):
if self.method_definition_has_integration(method_definition):
return True
return False |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_method_contents(self, method):
""" Returns the swagger contents of the given method. This checks to see if a conditional block has been used inside of th... |
if self._CONDITIONAL_IF in method:
return method[self._CONDITIONAL_IF][1:]
return [method] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_lambda_integration(self, path, method, integration_uri, method_auth_config=None, api_auth_config=None, condition=None):
""" Adds aws_proxy APIGW integrat... |
method = self._normalize_method_name(method)
if self.has_integration(path, method):
raise ValueError("Lambda integration already exists on Path={}, Method={}".format(path, method))
self.add_path(path, method)
# Wrap the integration_uri in a Condition if one exists on that... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def make_path_conditional(self, path, condition):
""" Wrap entire API path definition in a CloudFormation if condition. """ |
self.paths[path] = make_conditional(condition, self.paths[path]) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_cors(self, path, allowed_origins, allowed_headers=None, allowed_methods=None, max_age=None, allow_credentials=None):
""" Add CORS configuration to this p... |
# Skip if Options is already present
if self.has_path(path, self._OPTIONS_METHOD):
return
if not allowed_origins:
raise ValueError("Invalid input. Value for AllowedOrigins is required")
if not allowed_methods:
# AllowMethods is not given. Let's try... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _options_method_response_for_cors(self, allowed_origins, allowed_headers=None, allowed_methods=None, max_age=None, allow_credentials=None):
""" Returns a Swa... |
ALLOW_ORIGIN = "Access-Control-Allow-Origin"
ALLOW_HEADERS = "Access-Control-Allow-Headers"
ALLOW_METHODS = "Access-Control-Allow-Methods"
MAX_AGE = "Access-Control-Max-Age"
ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"
HEADER_RESPONSE = (lambda x: "method.resp... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_authorizers(self, authorizers):
""" Add Authorizer definitions to the securityDefinitions part of Swagger. :param list authorizers: List of Authorizer co... |
self.security_definitions = self.security_definitions or {}
for authorizer_name, authorizer in authorizers.items():
self.security_definitions[authorizer_name] = authorizer.generate_swagger() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_gateway_responses(self, gateway_responses):
""" Add Gateway Response definitions to Swagger. :param dict gateway_responses: Dictionary of GatewayResponse... |
self.gateway_responses = self.gateway_responses or {}
for response_type, response in gateway_responses.items():
self.gateway_responses[response_type] = response.generate_swagger() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def is_valid(data):
""" Checks if the input data is a Swagger document :param dict data: Data to be validated :return: True, if data is a Swagger """ |
return bool(data) and \
isinstance(data, dict) and \
bool(data.get("swagger")) and \
isinstance(data.get('paths'), dict) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _normalize_method_name(method):
""" Returns a lower case, normalized version of HTTP Method. It also know how to handle API Gateway specific methods like "AN... |
if not method or not isinstance(method, string_types):
return method
method = method.lower()
if method == 'any':
return SwaggerEditor._X_ANY_METHOD
else:
return method |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def is_type(valid_type):
"""Returns a validator function that succeeds only for inputs of the provided valid_type. :param type valid_type: the type that should b... |
def validate(value, should_raise=True):
if not isinstance(value, valid_type):
if should_raise:
raise TypeError("Expected value of type {expected}, actual value was of type {actual}.".format(
expected=valid_type, actual=type(value)))
return False
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list_of(validate_item):
"""Returns a validator function that succeeds only if the input is a list, and each item in the list passes as input to the provided ... |
def validate(value, should_raise=True):
validate_type = is_type(list)
if not validate_type(value, should_raise=should_raise):
return False
for item in value:
try:
validate_item(item)
except TypeError as e:
if should_raise:... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def dict_of(validate_key, validate_item):
"""Returns a validator function that succeeds only if the input is a dict, and each key and value in the dict passes as... |
def validate(value, should_raise=True):
validate_type = is_type(dict)
if not validate_type(value, should_raise=should_raise):
return False
for key, item in value.items():
try:
validate_key(key)
except TypeError as e:
if sh... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def one_of(*validators):
"""Returns a validator function that succeeds only if the input passes at least one of the provided validators. :param callable validato... |
def validate(value, should_raise=True):
if any(validate(value, should_raise=False) for validate in validators):
return True
if should_raise:
raise TypeError("value did not match any allowable type")
return False
return validate |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def to_statement(self, parameter_values):
""" With the given values for each parameter, this method will return a policy statement that can be used directly with... |
missing = self.missing_parameter_values(parameter_values)
if len(missing) > 0:
# str() of elements of list to prevent any `u` prefix from being displayed in user-facing error message
raise InsufficientParameterValues("Following required parameters of template '{}' don't have va... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def missing_parameter_values(self, parameter_values):
""" Checks if the given input contains values for all parameters used by this template :param dict paramete... |
if not self._is_valid_parameter_values(parameter_values):
raise InvalidParameterValues("Parameter values are required to process a policy template")
return list(set(self.parameters.keys()) - set(parameter_values.keys())) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_dict(template_name, template_values_dict):
""" Parses the input and returns an instance of this class. :param string template_name: Name of the template... |
parameters = template_values_dict.get("Parameters", {})
definition = template_values_dict.get("Definition", {})
return Template(template_name, parameters, definition) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def register(self, plugin):
""" Register a plugin. New plugins are added to the end of the plugins list. :param samtranslator.plugins.BasePlugin plugin: Instance... |
if not plugin or not isinstance(plugin, BasePlugin):
raise ValueError("Plugin must be implemented as a subclass of BasePlugin class")
if self.is_registered(plugin.name):
raise ValueError("Plugin with name {} is already registered".format(plugin.name))
self._plugins.ap... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _get(self, plugin_name):
""" Retrieves the plugin with given name :param plugin_name: Name of the plugin to retrieve :return samtranslator.plugins.BasePlugin... |
for p in self._plugins:
if p.name == plugin_name:
return p
return None |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def decrypt(message):
'''decrypt leverages KMS decrypt and base64-encode decrypted blob
More info on KMS decrypt API:
https://docs.aws.amazon.com/kms/latest/APIReference/API_decrypt.html
'''
try:
ret = kms.decrypt(
CiphertextBlob=base64.decodestring(message))
dec... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def lambda_handler(event, context):
'''Demonstrates S3 trigger that uses
Rekognition APIs to detect faces, labels and index faces in S3 Object.
'''
#print("Received event: " + json.dumps(event, indent=2))
# Get the object from the event
bucket = event['Records'][0]['s3']['bucket']['name']
k... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def _getStatementForEffect(self, effect, methods):
'''This function loops over an array of objects containing a resourceArn and
conditions statement and generates the array of statements for the policy.'''
statements = []
if len(methods) > 0:
statement = self._getEmptyStatem... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def lambda_handler(event, context):
'''A Python AWS Lambda function to process aggregated records sent to KinesisAnalytics.'''
raw_kpl_records = event['records']
output = [process_kpl_record(kpl_record) for kpl_record in raw_kpl_records]
# Print number of successful and failed records.
success_coun... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def transform(input_fragment, parameter_values, managed_policy_loader):
"""Translates the SAM manifest provided in the and returns the translation to CloudFormat... |
sam_parser = Parser()
translator = Translator(managed_policy_loader.load(), sam_parser)
return translator.translate(input_fragment, parameter_values=parameter_values) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def on_before_transform_template(self, template_dict):
""" Hook method that gets called before the SAM template is processed. The template has pass the validatio... |
template = SamTemplate(template_dict)
# Temporarily add Serverless::Api resource corresponding to Implicit API to the template.
# This will allow the processing code to work the same way for both Implicit & Explicit APIs
# If there are no implicit APIs, we will remove from the templat... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _get_api_events(self, function):
""" Method to return a dictionary of API Events on the function :param SamResource function: Function Resource object :retur... |
if not (function.valid() and
isinstance(function.properties, dict) and
isinstance(function.properties.get("Events"), dict)
):
# Function resource structure is invalid.
return {}
api_events = {}
for event_id, event in func... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _get_api_id(self, event_properties):
""" Get API logical id from API event properties. Handles case where API id is not specified or is a reference to a logi... |
api_id = event_properties.get("RestApiId")
if isinstance(api_id, dict) and "Ref" in api_id:
api_id = api_id["Ref"]
return api_id |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _add_combined_condition_to_template(self, template_dict, condition_name, conditions_to_combine):
""" Add top-level template condition that combines the given... |
# defensive precondition check
if not conditions_to_combine or len(conditions_to_combine) < 2:
raise ValueError('conditions_to_combine must have at least 2 conditions')
template_conditions = template_dict.setdefault('Conditions', {})
new_template_conditions = make_combined_... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _maybe_add_conditions_to_implicit_api_paths(self, template):
""" Add conditions to implicit API paths if necessary. Implicit API resource methods are constru... |
for api_id, api in template.iterate(SamResourceType.Api.value):
if not api.properties.get('__MANAGE_SWAGGER'):
continue
swagger = api.properties.get("DefinitionBody")
editor = SwaggerEditor(swagger)
for path in editor.iter_on_path():
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _path_condition_name(self, api_id, path):
""" Generate valid condition logical id from the given API logical id and swagger resource path. """ |
# only valid characters for CloudFormation logical id are [A-Za-z0-9], but swagger paths can contain
# slashes and curly braces for templated params, e.g., /foo/{customerId}. So we'll replace
# non-alphanumeric characters.
path_logical_id = path.replace('/', 'SLASH').replace('{', 'OB').... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def make_auto_deployable(self, stage, swagger=None):
""" Sets up the resource such that it will triggers a re-deployment when Swagger changes :param swagger: Dic... |
if not swagger:
return
# CloudFormation does NOT redeploy the API unless it has a new deployment resource
# that points to latest RestApi resource. Append a hash of Swagger Body location to
# redeploy only when the API data changes. First 10 characters of hash is good enoug... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def read(self, amt=None):
"""Read at most amt bytes from the stream. If the amt argument is omitted, read all data. """ |
chunk = self._raw_stream.read(amt)
self._amount_read += len(chunk)
return chunk |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _can_process_application(self, app):
""" Determines whether or not the on_before_transform_template event can process this application :param dict app: the a... |
return (self.LOCATION_KEY in app.properties and
isinstance(app.properties[self.LOCATION_KEY], dict) and
self.APPLICATION_ID_KEY in app.properties[self.LOCATION_KEY] and
self.SEMANTIC_VERSION_KEY in app.properties[self.LOCATION_KEY]) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_get_application_request(self, app_id, semver, key, logical_id):
""" Method that handles the get_application API call to the serverless application re... |
get_application = (lambda app_id, semver: self._sar_client.get_application(
ApplicationId=self._sanitize_sar_str_param(app_id),
SemanticVersion=self._sanitize_sar_str_param(semver)))
try:
self._sar_service_call(get_applic... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_create_cfn_template_request(self, app_id, semver, key, logical_id):
""" Method that handles the create_cloud_formation_template API call to the serve... |
create_cfn_template = (lambda app_id, semver: self._sar_client.create_cloud_formation_template(
ApplicationId=self._sanitize_sar_str_param(app_id),
SemanticVersion=self._sanitize_sar_str_param(semver)
))
response = self._sar_service_call(create_cfn_template, logical_id, ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _check_for_dictionary_key(self, logical_id, dictionary, keys):
""" Checks a dictionary to make sure it has a specific key. If it does not, an InvalidResource... |
for key in keys:
if key not in dictionary:
raise InvalidResourceException(logical_id, 'Resource is missing the required [{}] '
'property.'.format(key)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def on_after_transform_template(self, template):
""" Hook method that gets called after the template is processed Go through all the stored applications and make... |
if self._wait_for_template_active_status and not self._validate_only:
start_time = time()
while (time() - start_time) < self.TEMPLATE_WAIT_TIMEOUT_SECONDS:
temp = self._in_progress_templates
self._in_progress_templates = []
# Check each r... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_get_cfn_template_response(self, response, application_id, template_id):
""" Handles the response from the SAR service call :param dict response: the ... |
status = response['Status']
if status != "ACTIVE":
# Other options are PREPARING and EXPIRED.
if status == 'EXPIRED':
message = ("Template for {} with id {} returned status: {}. Cannot access an expired "
"template.".format(application_... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _sar_service_call(self, service_call_lambda, logical_id, *args):
""" Handles service calls and exception management for service calls to the Serverless Appli... |
try:
response = service_call_lambda(*args)
logging.info(response)
return response
except ClientError as e:
error_code = e.response['Error']['Code']
if error_code in ('AccessDeniedException', 'NotFoundException'):
raise InvalidR... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def iterate(self, resource_type=None):
""" Iterate over all resources within the SAM template, optionally filtering by type :param string resource_type: Optional... |
for logicalId, resource_dict in self.resources.items():
resource = SamResource(resource_dict)
needs_filter = resource.valid()
if resource_type:
needs_filter = needs_filter and resource.type == resource_type
if needs_filter:
yiel... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def set(self, logicalId, resource):
""" Adds the resource to dictionary with given logical Id. It will overwrite, if the logicalId is already used. :param string... |
resource_dict = resource
if isinstance(resource, SamResource):
resource_dict = resource.to_dict()
self.resources[logicalId] = resource_dict |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get(self, logicalId):
""" Gets the resource at the given logicalId if present :param string logicalId: Id of the resource :return SamResource: Resource, if a... |
if logicalId not in self.resources:
return None
return SamResource(self.resources.get(logicalId)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def prepare_plugins(plugins, parameters={}):
""" Creates & returns a plugins object with the given list of plugins installed. In addition to the given plugins, w... |
required_plugins = [
DefaultDefinitionBodyPlugin(),
make_implicit_api_plugin(),
GlobalsPlugin(),
make_policy_template_for_function_plugin(),
]
plugins = [] if not plugins else plugins
# If a ServerlessAppPlugin does not yet exist, create one and add to the beginning o... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def translate(self, sam_template, parameter_values):
"""Loads the SAM resources from the given SAM manifest, replaces them with their corresponding CloudFormatio... |
sam_parameter_values = SamParameterValues(parameter_values)
sam_parameter_values.add_default_parameter_values(sam_template)
sam_parameter_values.add_pseudo_parameter_values()
parameter_values = sam_parameter_values.parameter_values
# Create & Install plugins
sam_plugins ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _validate_logical_id(cls, logical_id):
"""Validates that the provided logical id is an alphanumeric string. :param str logical_id: the logical id to validate... |
pattern = re.compile(r'^[A-Za-z0-9]+$')
if logical_id is not None and pattern.match(logical_id):
return True
raise InvalidResourceException(logical_id, "Logical ids must be alphanumeric.") |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _validate_resource_dict(cls, logical_id, resource_dict):
"""Validates that the provided resource dict contains the correct Type string, and the required Prop... |
if 'Type' not in resource_dict:
raise InvalidResourceException(logical_id, "Resource dict missing key 'Type'.")
if resource_dict['Type'] != cls.resource_type:
raise InvalidResourceException(logical_id, "Resource has incorrect Type; expected '{expected}', "
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _generate_resource_dict(self):
"""Generates the resource dict for this Resource, the value associated with the logical id in a CloudFormation template's Reso... |
resource_dict = {}
resource_dict['Type'] = self.resource_type
if self.depends_on:
resource_dict['DependsOn'] = self.depends_on
resource_dict.update(self.resource_attributes)
properties_dict = {}
for name in self.property_types:
value = getattr... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def validate_properties(self):
"""Validates that the required properties for this Resource have been populated, and that all properties have valid values. :retur... |
for name, property_type in self.property_types.items():
value = getattr(self, name)
# If the property value is an intrinsic function, any remaining validation has to be left to CloudFormation
if property_type.supports_intrinsics and self._is_intrinsic_function(value):
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def set_resource_attribute(self, attr, value):
"""Sets attributes on resource. Resource attributes are top-level entries of a CloudFormation resource that exist ... |
if attr not in self._supported_resource_attributes:
raise KeyError("Unsupported resource attribute specified: %s" % attr)
self.resource_attributes[attr] = value |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_resource_attribute(self, attr):
"""Gets the resource attribute if available :param attr: Name of the attribute :return: Value of the attribute, if set in... |
if attr not in self.resource_attributes:
raise KeyError("%s is not in resource attributes" % attr)
return self.resource_attributes[attr] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_runtime_attr(self, attr_name):
""" Returns a CloudFormation construct that provides value for this attribute. If the resource does not provide this attri... |
if attr_name in self.runtime_attrs:
return self.runtime_attrs[attr_name](self)
else:
raise NotImplementedError(attr_name + " attribute is not implemented for resource " + self.resource_type) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def resolve_resource_type(self, resource_dict):
"""Returns the Resource class corresponding to the 'Type' key in the given resource dict. :param dict resource_di... |
if not self.can_resolve(resource_dict):
raise TypeError("Resource dict has missing or invalid value for key Type. Event Type is: {}.".format(
resource_dict.get('Type')))
if resource_dict['Type'] not in self.resource_types:
raise TypeError("Invalid resource ty... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def build_response_card(title, subtitle, options):
""" Build a responseCard with a title, subtitle, and an optional set of options which should be displayed as b... |
buttons = None
if options is not None:
buttons = []
for i in range(min(5, len(options))):
buttons.append(options[i])
return {
'contentType': 'application/vnd.amazonaws.card.generic',
'version': 1,
'genericAttachments': [{
'title': title,
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_availabilities(date):
""" Helper function which in a full implementation would feed into a backend API to provide query schedule availability. The output... |
day_of_week = dateutil.parser.parse(date).weekday()
availabilities = []
available_probability = 0.3
if day_of_week == 0:
start_hour = 10
while start_hour <= 16:
if random.random() < available_probability:
# Add an availability window for the given hour, with ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_availabilities_for_duration(duration, availabilities):
""" Helper function to return the windows of availability of the given duration, when provided a s... |
duration_availabilities = []
start_time = '10:00'
while start_time != '17:00':
if start_time in availabilities:
if duration == 30:
duration_availabilities.append(start_time)
elif increment_time_by_thirty_mins(start_time) in availabilities:
dur... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def build_available_time_string(availabilities):
""" Build a string eliciting for a possible time slot among at least two availabilities. """ |
prefix = 'We have availabilities at '
if len(availabilities) > 3:
prefix = 'We have plenty of availability, including '
prefix += build_time_output_string(availabilities[0])
if len(availabilities) == 2:
return '{} and {}'.format(prefix, build_time_output_string(availabilities[1]))
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def build_options(slot, appointment_type, date, booking_map):
""" Build a list of potential options for a given slot, to be used in responseCard generation. """ |
day_strings = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
if slot == 'AppointmentType':
return [
{'text': 'cleaning (30 min)', 'value': 'cleaning'},
{'text': 'root canal (60 min)', 'value': 'root canal'},
{'text': 'whitening (30 min)', 'value': 'whitening'}
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def is_instrinsic(input):
""" Checks if the given input is an intrinsic function dictionary. Intrinsic function is a dictionary with single key that is the name ... |
if input is not None \
and isinstance(input, dict) \
and len(input) == 1:
key = list(input.keys())[0]
return key == "Ref" or key == "Condition" or key.startswith("Fn::")
return False |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def can_handle(self, input_dict):
""" Validates that the input dictionary contains only one key and is of the given intrinsic_name :param input_dict: Input dicti... |
return input_dict is not None \
and isinstance(input_dict, dict) \
and len(input_dict) == 1 \
and self.intrinsic_name in input_dict |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _parse_resource_reference(cls, ref_value):
""" Splits a resource reference of structure "LogicalId.Property" and returns the "LogicalId" and "Property" separ... |
no_result = (None, None)
if not isinstance(ref_value, string_types):
return no_result
splits = ref_value.split(cls._resource_ref_separator, 1)
# Either there is no 'dot' (or) one of the values is empty string (Ex: when you split "LogicalId.")
if len(splits) != 2 o... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def resolve_parameter_refs(self, input_dict, parameters):
""" Resolves references that are present in the parameters and returns the value. If it is not in param... |
if not self.can_handle(input_dict):
return input_dict
param_name = input_dict[self.intrinsic_name]
if not isinstance(param_name, string_types):
return input_dict
if param_name in parameters:
return parameters[param_name]
else:
r... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def resolve_resource_refs(self, input_dict, supported_resource_refs):
""" Resolves references to some property of a resource. These are runtime properties which ... |
if not self.can_handle(input_dict):
return input_dict
ref_value = input_dict[self.intrinsic_name]
logical_id, property = self._parse_resource_reference(ref_value)
# ref_value could not be parsed
if not logical_id:
return input_dict
resolved_va... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_sub_action(self, input_dict, handler):
""" Handles resolving replacements in the Sub action based on the handler that is passed as an input. :param i... |
if not self.can_handle(input_dict):
return input_dict
key = self.intrinsic_name
sub_value = input_dict[key]
input_dict[key] = self._handle_sub_value(sub_value, handler)
return input_dict |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _get_resolved_dictionary(self, input_dict, key, resolved_value, remaining):
""" Resolves the function and returns the updated dictionary :param input_dict: D... |
if resolved_value:
# We resolved to a new resource logicalId. Use this as the first element and keep remaining elements intact
# This is the new value of Fn::GetAtt
input_dict[key] = [resolved_value] + remaining
return input_dict |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def lambda_handler(event, context):
''' Process a RDS enhenced monitoring DATA_MESSAGE,
coming from CLOUDWATCH LOGS
'''
# event is a dict containing a base64 string gzipped
event = json.loads(gzip.GzipFile(fileobj=StringIO(event['awslogs']['data'].decode('base64'))).read())
account = event[... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _construct_rest_api(self):
"""Constructs and returns the ApiGateway RestApi. :returns: the RestApi to which this SAM Api corresponds :rtype: model.apigateway... |
rest_api = ApiGatewayRestApi(self.logical_id, depends_on=self.depends_on, attributes=self.resource_attributes)
rest_api.BinaryMediaTypes = self.binary_media
rest_api.MinimumCompressionSize = self.minimum_compression_size
if self.endpoint_configuration:
self._set_endpoint_co... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _construct_body_s3_dict(self):
"""Constructs the RestApi's `BodyS3Location property`_, from the SAM Api's DefinitionUri property. :returns: a BodyS3Location ... |
if isinstance(self.definition_uri, dict):
if not self.definition_uri.get("Bucket", None) or not self.definition_uri.get("Key", None):
# DefinitionUri is a dictionary but does not contain Bucket or Key property
raise InvalidResourceException(self.logical_id,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.