コード例 #1
0
ファイル: models.py プロジェクト: tmwong2003/moto
    def list_query_logging_configs(self, hosted_zone_id=None):
        """Return a list of query logging configs."""
        if hosted_zone_id:
            # Does the hosted_zone_id exist?
            response = self.list_hosted_zones()
            zones = list(response) if response else []
            for zone in zones:
                if zone.id == hosted_zone_id:
                    break
            else:
                raise NoSuchHostedZone(hosted_zone_id)

        return list(self.query_logging_configs.values())
コード例 #2
0
    def list_query_logging_configs(
        self, hosted_zone_id=None, next_token=None, max_results=None,
    ):  # pylint: disable=unused-argument
        """Return a list of query logging configs."""
        if hosted_zone_id:
            # Does the hosted_zone_id exist?
            response = self.list_hosted_zones()
            zones = list(response) if response else []
            for zone in zones:
                if zone.id == hosted_zone_id:
                    break
            else:
                raise NoSuchHostedZone(hosted_zone_id)

        return list(self.query_logging_configs.values())
コード例 #3
0
ファイル: models.py プロジェクト: mdavis-xyz/moto
    def create_query_logging_config(self, region, hosted_zone_id,
                                    log_group_arn):
        """Process the create_query_logging_config request."""
        # Does the hosted_zone_id exist?
        response = self.list_hosted_zones()
        zones = list(response) if response else []
        for zone in zones:
            if zone.id == hosted_zone_id:
                break
        else:
            raise NoSuchHostedZone(hosted_zone_id)

        # Ensure CloudWatch Logs log ARN is valid, otherwise raise an error.
        self._validate_arn(region, log_group_arn)

        # Note:  boto3 checks the resource policy permissions before checking
        # whether the log group exists.  moto doesn't have a way of checking
        # the resource policy, so in some instances moto will complain
        # about a log group that doesn't exist whereas boto3 will complain
        # that "The resource policy that you're using for Route 53 query
        # logging doesn't grant Route 53 sufficient permission to create
        # a log stream in the specified log group."

        from moto.logs import logs_backends  # pylint: disable=import-outside-toplevel

        response = logs_backends[region].describe_log_groups()
        log_groups = response[0] if response else []
        for entry in log_groups:
            if log_group_arn == entry["arn"]:
                break
        else:
            # There is no CloudWatch Logs log group with the specified ARN.
            raise NoSuchCloudWatchLogsLogGroup()

        # Verify there is no existing query log config using the same hosted
        # zone.
        for query_log in self.query_logging_configs.values():
            if query_log.hosted_zone_id == hosted_zone_id:
                raise QueryLoggingConfigAlreadyExists()

        # Create an instance of the query logging config.
        query_logging_config_id = str(uuid.uuid4())
        query_logging_config = QueryLoggingConfig(query_logging_config_id,
                                                  hosted_zone_id,
                                                  log_group_arn)
        self.query_logging_configs[
            query_logging_config_id] = query_logging_config
        return query_logging_config
コード例 #4
0
ファイル: models.py プロジェクト: tmwong2003/moto
 def get_hosted_zone(self, id_):
     the_zone = self.zones.get(id_.replace("/hostedzone/", ""))
     if not the_zone:
         raise NoSuchHostedZone(id_)
     return the_zone