"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.CfnResourcePolicyPropsMixin = exports.CfnStreamConsumerPropsMixin = exports.CfnStreamPropsMixin = 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-kinesis"));
/**
 * Creates a Kinesis stream that captures and transports data records that are emitted from data sources.
 *
 * For information about creating streams, see [CreateStream](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_CreateStream.html) in the Amazon Kinesis API Reference.
 *
 * @cloudformationResource AWS::Kinesis::Stream
 * @mixin true
 * @stability external
 * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kinesis-stream.html
 */
class CfnStreamPropsMixin extends cdk.Mixin {
    static [JSII_RTTI_SYMBOL_1] = { fqn: "@aws-cdk/cfn-property-mixins.aws_kinesis.CfnStreamPropsMixin", version: "2.258.1" };
    static CFN_PROPERTY_KEYS = ["desiredShardLevelMetrics", "maxRecordSizeInKiB", "name", "retentionPeriodHours", "shardCount", "streamEncryption", "streamModeDetails", "tags", "warmThroughputMiBps"];
    props;
    strategy;
    /**
     * Create a mixin to apply properties to `AWS::Kinesis::Stream`.
     *
     * @param props L1 properties to apply
     * @param options Mixin options
     */
    constructor(props, options = {}) {
        super();
        try {
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_aws_kinesis_CfnStreamMixinProps(props);
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_CfnPropertyMixinOptions(options);
        }
        catch (error) {
            if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
                Error.captureStackTrace(error, CfnStreamPropsMixin);
            }
            throw error;
        }
        this.props = {
            ...props,
            ...flattenCfnStreamMixinProps(props)
        };
        this.strategy = (options.strategy ?? cdk.PropertyMergeStrategy.combine());
    }
    /**
     * Check if this mixin supports the given construct
     */
    supports(construct) {
        return (cdk.CfnResource.isCfnResource(construct) && service.CfnStream.isCfnStream(construct));
    }
    /**
     * Apply the mixin properties to the construct
     */
    applyTo(construct) {
        if (this.supports(construct)) {
            this.strategy.apply(construct, this.props, CfnStreamPropsMixin.CFN_PROPERTY_KEYS);
        }
    }
}
exports.CfnStreamPropsMixin = CfnStreamPropsMixin;
// @ts-ignore TS6133
function flattenCfnStreamPropsMixinStreamEncryptionProperty(props) {
    if (cdk.isResolvableObject(props))
        return props;
    return {
        encryptionType: (!props.encryptionType ? undefined : props.encryptionType),
        keyId: (!props.keyId ? undefined : cdk.getRefProperty(props.keyId?.keyRef, 'keyArn') ?? cdk.getRefProperty(props.keyId?.keyRef, 'keyId') ?? cdk.ensureStringOrUndefined(props.keyId, "keyId", "kms.IKeyRef | string"))
    };
}
// @ts-ignore TS6133
function flattenCfnStreamMixinProps(props) {
    const ret = {};
    if ((props.streamEncryption !== undefined))
        ret.streamEncryption = flattenCfnStreamPropsMixinStreamEncryptionProperty(props.streamEncryption);
    return ret;
}
/**
 * Use the AWS CloudFormation `AWS::Kinesis::StreamConsumer` resource to register a consumer with a Kinesis data stream.
 *
 * The consumer you register can then call [SubscribeToShard](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_SubscribeToShard.html) to receive data from the stream using enhanced fan-out, at a rate of up to 2 MiB per second for every shard you subscribe to. This rate is unaffected by the total number of consumers that read from the same stream.
 *
 * You can register up to 20 consumers per stream. However, you can request a limit increase using the [Kinesis Data Streams limits form](https://docs.aws.amazon.com/support/v1?#/) . A given consumer can only be registered with one stream at a time.
 *
 * For more information, see [Using Consumers with Enhanced Fan-Out](https://docs.aws.amazon.com/streams/latest/dev/introduction-to-enhanced-consumers.html) .
 *
 * @cloudformationResource AWS::Kinesis::StreamConsumer
 * @mixin true
 * @stability external
 * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kinesis-streamconsumer.html
 */
class CfnStreamConsumerPropsMixin extends cdk.Mixin {
    static [JSII_RTTI_SYMBOL_1] = { fqn: "@aws-cdk/cfn-property-mixins.aws_kinesis.CfnStreamConsumerPropsMixin", version: "2.258.1" };
    static CFN_PROPERTY_KEYS = ["consumerName", "streamArn", "tags"];
    props;
    strategy;
    /**
     * Create a mixin to apply properties to `AWS::Kinesis::StreamConsumer`.
     *
     * @param props L1 properties to apply
     * @param options Mixin options
     */
    constructor(props, options = {}) {
        super();
        try {
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_aws_kinesis_CfnStreamConsumerMixinProps(props);
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_CfnPropertyMixinOptions(options);
        }
        catch (error) {
            if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
                Error.captureStackTrace(error, CfnStreamConsumerPropsMixin);
            }
            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.CfnStreamConsumer.isCfnStreamConsumer(construct));
    }
    /**
     * Apply the mixin properties to the construct
     */
    applyTo(construct) {
        if (this.supports(construct)) {
            this.strategy.apply(construct, this.props, CfnStreamConsumerPropsMixin.CFN_PROPERTY_KEYS);
        }
    }
}
exports.CfnStreamConsumerPropsMixin = CfnStreamConsumerPropsMixin;
/**
 * Attaches a resource-based policy to a data stream or registered consumer.
 *
 * If you are using an identity other than the root user of the AWS account that owns the resource, the calling identity must have the `PutResourcePolicy` permissions on the specified Kinesis Data Streams resource and belong to the owner's account in order to use this operation. If you don't have `PutResourcePolicy` permissions, Amazon Kinesis Data Streams returns a `403 Access Denied error` . If you receive a `ResourceNotFoundException` , check to see if you passed a valid stream or consumer resource.
 *
 * Request patterns can be one of the following:
 *
 * - Data stream pattern: `arn:aws.*:kinesis:.*:\d{12}:.*stream/\S+`
 * - Consumer pattern: `^(arn):aws.*:kinesis:.*:\d{12}:.*stream\/[a-zA-Z0-9_.-]+\/consumer\/[a-zA-Z0-9_.-]+:[0-9]+`
 *
 * For more information, see [Controlling Access to Amazon Kinesis Data Streams Resources Using IAM](https://docs.aws.amazon.com/streams/latest/dev/controlling-access.html) .
 *
 * @cloudformationResource AWS::Kinesis::ResourcePolicy
 * @mixin true
 * @stability external
 * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kinesis-resourcepolicy.html
 */
class CfnResourcePolicyPropsMixin extends cdk.Mixin {
    static [JSII_RTTI_SYMBOL_1] = { fqn: "@aws-cdk/cfn-property-mixins.aws_kinesis.CfnResourcePolicyPropsMixin", version: "2.258.1" };
    static CFN_PROPERTY_KEYS = ["resourceArn", "resourcePolicy"];
    props;
    strategy;
    /**
     * Create a mixin to apply properties to `AWS::Kinesis::ResourcePolicy`.
     *
     * @param props L1 properties to apply
     * @param options Mixin options
     */
    constructor(props, options = {}) {
        super();
        try {
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_aws_kinesis_CfnResourcePolicyMixinProps(props);
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_CfnPropertyMixinOptions(options);
        }
        catch (error) {
            if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
                Error.captureStackTrace(error, CfnResourcePolicyPropsMixin);
            }
            throw error;
        }
        this.props = {
            ...props,
            ...flattenCfnResourcePolicyMixinProps(props)
        };
        this.strategy = (options.strategy ?? cdk.PropertyMergeStrategy.combine());
    }
    /**
     * Check if this mixin supports the given construct
     */
    supports(construct) {
        return (cdk.CfnResource.isCfnResource(construct) && service.CfnResourcePolicy.isCfnResourcePolicy(construct));
    }
    /**
     * Apply the mixin properties to the construct
     */
    applyTo(construct) {
        if (this.supports(construct)) {
            this.strategy.apply(construct, this.props, CfnResourcePolicyPropsMixin.CFN_PROPERTY_KEYS);
        }
    }
}
exports.CfnResourcePolicyPropsMixin = CfnResourcePolicyPropsMixin;
// @ts-ignore TS6133
function flattenCfnResourcePolicyMixinProps(props) {
    const ret = {};
    if ((props.resourceArn !== undefined))
        ret.resourceArn = cdk.getRefProperty(props.resourceArn?.streamRef, 'streamArn') ?? cdk.getRefProperty(props.resourceArn?.streamConsumerRef, 'consumerArn') ?? cdk.ensureStringOrUndefined(props.resourceArn, "resourceArn", "kinesis.IStreamRef | kinesis.IStreamConsumerRef | string");
    return ret;
}
