"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CfnGroupPropsMixin = exports.CfnCanaryPropsMixin = void 0;
const jsiiDeprecationWarnings = require("../../../.warnings.jsii.js");
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
/* eslint-disable @stylistic/max-len, eol-last */
const cdk = __importStar(require("aws-cdk-lib/core"));
const service = __importStar(require("aws-cdk-lib/aws-synthetics"));
/**
 * Creates or updates a canary.
 *
 * Canaries are scripts that monitor your endpoints and APIs from the outside-in. Canaries help you check the availability and latency of your web services and troubleshoot anomalies by investigating load time data, screenshots of the UI, logs, and metrics. You can set up a canary to run continuously or just once.
 *
 * Canaries are automated scripts that run at specified intervals against an endpoint. They include Python or Node.js code to create a Lambda function. This code needs to be packaged in a certain way, depending on the language. For more information, see [Writing a canary script](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_WritingCanary.html) .
 *
 * To create canaries, you must have the `CloudWatchSyntheticsFullAccess` policy. If you are creating a new IAM role for the canary, you also need the the `iam:CreateRole` , `iam:CreatePolicy` and `iam:AttachRolePolicy` permissions. For more information, see [Necessary Roles and Permissions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Roles) .
 *
 * Do not include secrets or proprietary information in your canary names. The canary name makes up part of the Amazon Resource Name (ARN) for the canary, and the ARN is included in outbound calls over the internet. For more information, see [Security Considerations for Synthetics Canaries](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/servicelens_canaries_security.html) .
 *
 * @cloudformationResource AWS::Synthetics::Canary
 * @mixin true
 * @stability external
 * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html
 */
class CfnCanaryPropsMixin extends cdk.Mixin {
    static [JSII_RTTI_SYMBOL_1] = { fqn: "@aws-cdk/cfn-property-mixins.aws_synthetics.CfnCanaryPropsMixin", version: "2.258.1" };
    static CFN_PROPERTY_KEYS = ["artifactConfig", "artifactS3Location", "browserConfigs", "code", "deleteLambdaResourcesOnCanaryDeletion", "dryRunAndUpdate", "executionRoleArn", "failureRetentionPeriod", "name", "provisionedResourceCleanup", "resourcesToReplicateTags", "runConfig", "runtimeVersion", "schedule", "startCanaryAfterCreation", "successRetentionPeriod", "tags", "visualReference", "visualReferences", "vpcConfig"];
    props;
    strategy;
    /**
     * Create a mixin to apply properties to `AWS::Synthetics::Canary`.
     *
     * @param props L1 properties to apply
     * @param options Mixin options
     */
    constructor(props, options = {}) {
        super();
        try {
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_aws_synthetics_CfnCanaryMixinProps(props);
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_CfnPropertyMixinOptions(options);
        }
        catch (error) {
            if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
                Error.captureStackTrace(error, CfnCanaryPropsMixin);
            }
            throw error;
        }
        this.props = {
            ...props,
            ...flattenCfnCanaryMixinProps(props)
        };
        this.strategy = (options.strategy ?? cdk.PropertyMergeStrategy.combine());
    }
    /**
     * Check if this mixin supports the given construct
     */
    supports(construct) {
        return (cdk.CfnResource.isCfnResource(construct) && service.CfnCanary.isCfnCanary(construct));
    }
    /**
     * Apply the mixin properties to the construct
     */
    applyTo(construct) {
        if (this.supports(construct)) {
            this.strategy.apply(construct, this.props, CfnCanaryPropsMixin.CFN_PROPERTY_KEYS);
        }
    }
}
exports.CfnCanaryPropsMixin = CfnCanaryPropsMixin;
// @ts-ignore TS6133
function flattenCfnCanaryPropsMixinVPCConfigProperty(props) {
    if (cdk.isResolvableObject(props))
        return props;
    return {
        ipv6AllowedForDualStack: (!props.ipv6AllowedForDualStack ? undefined : props.ipv6AllowedForDualStack),
        securityGroupIds: (!props.securityGroupIds ? undefined : props.securityGroupIds),
        subnetIds: (!props.subnetIds ? undefined : cdk.mapArrayInPlace(props.subnetIds, (item) => cdk.getRefProperty(item?.subnetRef, 'subnetId') ?? cdk.ensureStringOrUndefined(item, "subnetIds", "ec2.ISubnetRef | string"))),
        vpcId: (!props.vpcId ? undefined : cdk.getRefProperty(props.vpcId?.vpcRef, 'vpcId') ?? cdk.ensureStringOrUndefined(props.vpcId, "vpcId", "ec2.IVPCRef | string"))
    };
}
// @ts-ignore TS6133
function flattenCfnCanaryPropsMixinCodeProperty(props) {
    if (cdk.isResolvableObject(props))
        return props;
    return {
        blueprintTypes: (!props.blueprintTypes ? undefined : props.blueprintTypes),
        dependencies: (!props.dependencies ? undefined : props.dependencies),
        handler: (!props.handler ? undefined : props.handler),
        s3Bucket: (!props.s3Bucket ? undefined : cdk.getRefProperty(props.s3Bucket?.bucketRef, 'bucketName') ?? cdk.ensureStringOrUndefined(props.s3Bucket, "s3Bucket", "s3.IBucketRef | string")),
        s3Key: (!props.s3Key ? undefined : props.s3Key),
        s3ObjectVersion: (!props.s3ObjectVersion ? undefined : props.s3ObjectVersion),
        script: (!props.script ? undefined : props.script),
        sourceLocationArn: (!props.sourceLocationArn ? undefined : props.sourceLocationArn)
    };
}
// @ts-ignore TS6133
function flattenCfnCanaryMixinProps(props) {
    const ret = {};
    if ((props.code !== undefined))
        ret.code = flattenCfnCanaryPropsMixinCodeProperty(props.code);
    if ((props.executionRoleArn !== undefined))
        ret.executionRoleArn = cdk.getRefProperty(props.executionRoleArn?.roleRef, 'roleArn') ?? cdk.ensureStringOrUndefined(props.executionRoleArn, "executionRoleArn", "iam.IRoleRef | string");
    if ((props.vpcConfig !== undefined))
        ret.vpcConfig = flattenCfnCanaryPropsMixinVPCConfigProperty(props.vpcConfig);
    return ret;
}
/**
 * Creates or updates a group which you can use to associate canaries with each other, including cross-Region canaries.
 *
 * Using groups can help you with managing and automating your canaries, and you can also view aggregated run results and statistics for all canaries in a group.
 *
 * Groups are global resources. When you create a group, it is replicated across all AWS Regions, and you can add canaries from any Region to it, and view it in any Region. Although the group ARN format reflects the Region name where it was created, a group is not constrained to any Region. This means that you can put canaries from multiple Regions into the same group, and then use that group to view and manage all of those canaries in a single view.
 *
 * Each group can contain as many as 10 canaries. You can have as many as 20 groups in your account. Any single canary can be a member of up to 10 groups.
 *
 * @cloudformationResource AWS::Synthetics::Group
 * @mixin true
 * @stability external
 * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-group.html
 */
class CfnGroupPropsMixin extends cdk.Mixin {
    static [JSII_RTTI_SYMBOL_1] = { fqn: "@aws-cdk/cfn-property-mixins.aws_synthetics.CfnGroupPropsMixin", version: "2.258.1" };
    static CFN_PROPERTY_KEYS = ["name", "resourceArns", "tags"];
    props;
    strategy;
    /**
     * Create a mixin to apply properties to `AWS::Synthetics::Group`.
     *
     * @param props L1 properties to apply
     * @param options Mixin options
     */
    constructor(props, options = {}) {
        super();
        try {
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_aws_synthetics_CfnGroupMixinProps(props);
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_CfnPropertyMixinOptions(options);
        }
        catch (error) {
            if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
                Error.captureStackTrace(error, CfnGroupPropsMixin);
            }
            throw error;
        }
        this.props = props;
        this.strategy = (options.strategy ?? cdk.PropertyMergeStrategy.combine());
    }
    /**
     * Check if this mixin supports the given construct
     */
    supports(construct) {
        return (cdk.CfnResource.isCfnResource(construct) && service.CfnGroup.isCfnGroup(construct));
    }
    /**
     * Apply the mixin properties to the construct
     */
    applyTo(construct) {
        if (this.supports(construct)) {
            this.strategy.apply(construct, this.props, CfnGroupPropsMixin.CFN_PROPERTY_KEYS);
        }
    }
}
exports.CfnGroupPropsMixin = CfnGroupPropsMixin;
