"use strict";
// Copyright 2012-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// Generated from the AWS CloudFormation Resource Specification
// See: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html
// @cfn2ts:meta@ {"generated":"2018-08-15T13:37:37.238Z","fingerprint":"HC25IiLYn5ceSY9ZHNW99lKazLfPulTTt3Tjle/abYg="}
Object.defineProperty(exports, "__esModule", { value: true });
// tslint:disable:max-line-length | This is generated code - line lengths are difficult to control
const cdk = require("@aws-cdk/cdk");
var cloudformation;
(function (cloudformation) {
    /**
     * Determine whether the given properties match those of a ``AliasResourceProps``
     *
     * @param properties the TypeScript properties of a ``AliasResourceProps``
     *
     * @returns the result of the validation.
     */
    function AliasResourcePropsValidator(properties) {
        if (!cdk.canInspect(properties)) {
            return cdk.VALIDATION_SUCCESS;
        }
        const errors = new cdk.ValidationResults();
        errors.collect(cdk.propertyValidator('aliasName', cdk.requiredValidator)(properties.aliasName));
        errors.collect(cdk.propertyValidator('aliasName', cdk.validateString)(properties.aliasName));
        errors.collect(cdk.propertyValidator('targetKeyId', cdk.requiredValidator)(properties.targetKeyId));
        errors.collect(cdk.propertyValidator('targetKeyId', cdk.validateString)(properties.targetKeyId));
        return errors.wrap('supplied properties not correct for "AliasResourceProps"');
    }
    /**
     * Renders the AWS CloudFormation properties of an ``AWS::KMS::Alias`` resource
     *
     * @param properties the TypeScript properties of a ``AliasResourceProps``
     *
     * @returns the AWS CloudFormation properties of an ``AWS::KMS::Alias`` resource.
     */
    function aliasResourcePropsToCloudFormation(properties) {
        if (!cdk.canInspect(properties)) {
            return properties;
        }
        AliasResourcePropsValidator(properties).assertSuccess();
        return {
            AliasName: cdk.stringToCloudFormation(properties.aliasName),
            TargetKeyId: cdk.stringToCloudFormation(properties.targetKeyId),
        };
    }
    /**
     * @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html
     */
    class AliasResource extends cdk.Resource {
        /**
         * Creates a new ``AWS::KMS::Alias``.
         *
         * @param parent     the ``cdk.Construct`` this ``AliasResource`` is a part of
         * @param name       the name of the resource in the ``cdk.Construct`` tree
         * @param properties the properties of this ``AliasResource``
         */
        constructor(parent, name, properties) {
            super(parent, name, { type: AliasResource.resourceTypeName, properties });
            cdk.requireProperty(properties, 'aliasName', this);
            cdk.requireProperty(properties, 'targetKeyId', this);
        }
        renderProperties() {
            return aliasResourcePropsToCloudFormation(cdk.resolve(this.properties));
        }
    }
    /**
     * The CloudFormation resource type name for this resource class.
     */
    AliasResource.resourceTypeName = "AWS::KMS::Alias";
    cloudformation.AliasResource = AliasResource;
})(cloudformation = exports.cloudformation || (exports.cloudformation = {}));
(function (cloudformation) {
    /**
     * Determine whether the given properties match those of a ``KeyResourceProps``
     *
     * @param properties the TypeScript properties of a ``KeyResourceProps``
     *
     * @returns the result of the validation.
     */
    function KeyResourcePropsValidator(properties) {
        if (!cdk.canInspect(properties)) {
            return cdk.VALIDATION_SUCCESS;
        }
        const errors = new cdk.ValidationResults();
        errors.collect(cdk.propertyValidator('description', cdk.validateString)(properties.description));
        errors.collect(cdk.propertyValidator('enableKeyRotation', cdk.validateBoolean)(properties.enableKeyRotation));
        errors.collect(cdk.propertyValidator('enabled', cdk.validateBoolean)(properties.enabled));
        errors.collect(cdk.propertyValidator('keyPolicy', cdk.requiredValidator)(properties.keyPolicy));
        errors.collect(cdk.propertyValidator('keyPolicy', cdk.validateObject)(properties.keyPolicy));
        errors.collect(cdk.propertyValidator('keyUsage', cdk.validateString)(properties.keyUsage));
        errors.collect(cdk.propertyValidator('tags', cdk.listValidator(cdk.validateTag))(properties.tags));
        return errors.wrap('supplied properties not correct for "KeyResourceProps"');
    }
    /**
     * Renders the AWS CloudFormation properties of an ``AWS::KMS::Key`` resource
     *
     * @param properties the TypeScript properties of a ``KeyResourceProps``
     *
     * @returns the AWS CloudFormation properties of an ``AWS::KMS::Key`` resource.
     */
    function keyResourcePropsToCloudFormation(properties) {
        if (!cdk.canInspect(properties)) {
            return properties;
        }
        KeyResourcePropsValidator(properties).assertSuccess();
        return {
            KeyPolicy: cdk.objectToCloudFormation(properties.keyPolicy),
            Description: cdk.stringToCloudFormation(properties.description),
            Enabled: cdk.booleanToCloudFormation(properties.enabled),
            EnableKeyRotation: cdk.booleanToCloudFormation(properties.enableKeyRotation),
            KeyUsage: cdk.stringToCloudFormation(properties.keyUsage),
            Tags: cdk.listMapper(cdk.tagToCloudFormation)(properties.tags),
        };
    }
    /**
     * @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html
     */
    class KeyResource extends cdk.Resource {
        /**
         * Creates a new ``AWS::KMS::Key``.
         *
         * @param parent     the ``cdk.Construct`` this ``KeyResource`` is a part of
         * @param name       the name of the resource in the ``cdk.Construct`` tree
         * @param properties the properties of this ``KeyResource``
         */
        constructor(parent, name, properties) {
            super(parent, name, { type: KeyResource.resourceTypeName, properties });
            cdk.requireProperty(properties, 'keyPolicy', this);
            this.keyArn = new KeyArn(this.getAtt('Arn'));
        }
        renderProperties() {
            return keyResourcePropsToCloudFormation(cdk.resolve(this.properties));
        }
    }
    /**
     * The CloudFormation resource type name for this resource class.
     */
    KeyResource.resourceTypeName = "AWS::KMS::Key";
    cloudformation.KeyResource = KeyResource;
})(cloudformation = exports.cloudformation || (exports.cloudformation = {}));
class KeyArn extends cdk.Arn {
}
exports.KeyArn = KeyArn;
//# sourceMappingURL=data:application/json;base64, 