How to use the moto.core.utils.amzn_request_id function in moto

To help you get started, we’ve selected a few moto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spulec / moto / moto / elbv2 / responses.py View on Github external
    @amzn_request_id
    def modify_listener(self):
        arn = self._get_param("ListenerArn")
        port = self._get_param("Port")
        protocol = self._get_param("Protocol")
        ssl_policy = self._get_param("SslPolicy")
        certificates = self._get_list_prefix("Certificates.member")
        default_actions = self._get_list_prefix("DefaultActions.member")

        # Should really move SSL Policies to models
        if ssl_policy is not None and ssl_policy not in [
            item["name"] for item in SSL_POLICIES
        ]:
            raise RESTError(
                "SSLPolicyNotFound", "Policy {0} not found".format(ssl_policy)
            )
github spulec / moto / moto / elbv2 / responses.py View on Github external
    @amzn_request_id
    def describe_ssl_policies(self):
        names = self._get_multi_param("Names.member.")
        # Supports paging but not worth implementing yet
        # marker = self._get_param('Marker')
        # page_size = self._get_int_param('PageSize')

        policies = SSL_POLICIES
        if names:
            policies = filter(lambda policy: policy["name"] in names, policies)

        template = self.response_template(DESCRIBE_SSL_POLICIES_TEMPLATE)
        return template.render(policies=policies)
github spulec / moto / moto / elbv2 / responses.py View on Github external
    @amzn_request_id
    def describe_load_balancers(self):
        arns = self._get_multi_param("LoadBalancerArns.member")
        names = self._get_multi_param("Names.member")
        all_load_balancers = list(
            self.elbv2_backend.describe_load_balancers(arns, names)
        )
        marker = self._get_param("Marker")
        all_names = [balancer.name for balancer in all_load_balancers]
        if marker:
            start = all_names.index(marker) + 1
        else:
            start = 0
        page_size = self._get_int_param(
            "PageSize", 50
        )  # the default is 400, but using 50 to make testing easier
        load_balancers_resp = all_load_balancers[start : start + page_size]
github spulec / moto / moto / autoscaling / responses.py View on Github external
    @amzn_request_id
    def attach_instances(self):
        group_name = self._get_param("AutoScalingGroupName")
        instance_ids = self._get_multi_param("InstanceIds.member")
        self.autoscaling_backend.attach_instances(group_name, instance_ids)
        template = self.response_template(ATTACH_INSTANCES_TEMPLATE)
        return template.render()
github spulec / moto / moto / awslambda / responses.py View on Github external
    @amzn_request_id
    def invoke_async(self, request, full_url, headers):
        self.setup_class(request, full_url, headers)
        if request.method == "POST":
            return self._invoke_async(request, full_url)
        else:
            raise ValueError("Cannot handle request")
github spulec / moto / moto / autoscaling / responses.py View on Github external
    @amzn_request_id
    def detach_instances(self):
        group_name = self._get_param("AutoScalingGroupName")
        instance_ids = self._get_multi_param("InstanceIds.member")
        should_decrement_string = self._get_param("ShouldDecrementDesiredCapacity")
        if should_decrement_string == "true":
            should_decrement = True
        else:
            should_decrement = False
        detached_instances = self.autoscaling_backend.detach_instances(
            group_name, instance_ids, should_decrement
        )
        template = self.response_template(DETACH_INSTANCES_TEMPLATE)
        return template.render(detached_instances=detached_instances)
github spulec / moto / moto / cloudwatch / responses.py View on Github external
    @amzn_request_id
    def list_dashboards(self):
        prefix = self._get_param("DashboardNamePrefix", "")

        dashboards = self.cloudwatch_backend.list_dashboards(prefix)

        template = self.response_template(LIST_DASHBOARD_RESPONSE)
        return template.render(dashboards=dashboards)
github spulec / moto / moto / stepfunctions / responses.py View on Github external
    @amzn_request_id
    def describe_execution(self):
        arn = self._get_param("executionArn")
        try:
            execution = self.stepfunction_backend.describe_execution(arn)
            response = {
                "executionArn": arn,
                "input": "{}",
                "name": execution.name,
                "startDate": execution.start_date,
                "stateMachineArn": execution.state_machine_arn,
                "status": execution.status,
                "stopDate": execution.stop_date,
            }
            return 200, {}, json.dumps(response)
        except AWSError as err:
            return err.response()
github spulec / moto / moto / stepfunctions / responses.py View on Github external
    @amzn_request_id
    def describe_state_machine(self):
        arn = self._get_param("stateMachineArn")
        return self._describe_state_machine(arn)
github spulec / moto / moto / cloudwatch / responses.py View on Github external
    @amzn_request_id
    def describe_alarms(self):
        action_prefix = self._get_param("ActionPrefix")
        alarm_name_prefix = self._get_param("AlarmNamePrefix")
        alarm_names = self._get_multi_param("AlarmNames.member")
        state_value = self._get_param("StateValue")

        if action_prefix:
            alarms = self.cloudwatch_backend.get_alarms_by_action_prefix(action_prefix)
        elif alarm_name_prefix:
            alarms = self.cloudwatch_backend.get_alarms_by_alarm_name_prefix(
                alarm_name_prefix
            )
        elif alarm_names:
            alarms = self.cloudwatch_backend.get_alarms_by_alarm_names(alarm_names)
        elif state_value:
            alarms = self.cloudwatch_backend.get_alarms_by_state_value(state_value)