UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.26 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Deployment=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),helpers_internal_1=require("../../core/lib/helpers-internal"),apigateway_generated_1=require("./apigateway.generated"),restapi_1=require("./restapi");class Deployment extends core_1.Resource{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_apigateway_DeploymentProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Deployment),error}this.resource=new LatestDeploymentResource(this,"Resource",{description:props.description,restApi:props.api}),props.retainDeployments&&this.resource.applyRemovalPolicy(core_1.RemovalPolicy.RETAIN),this.api=props.api,this.deploymentId=core_1.Lazy.string({produce:()=>this.resource.ref}),props.api instanceof restapi_1.RestApiBase&&props.api._attachDeployment(this)}addToLogicalId(data){this.resource.addToLogicalId(data)}_addMethodDependency(method){this.node.addDependency(method.node.defaultChild)}}exports.Deployment=Deployment,_a=JSII_RTTI_SYMBOL_1,Deployment[_a]={fqn:"aws-cdk-lib.aws_apigateway.Deployment",version:"2.70.0"};class LatestDeploymentResource extends apigateway_generated_1.CfnDeployment{constructor(scope,id,props){super(scope,id,{description:props.description,restApiId:props.restApi.restApiId}),this.hashComponents=new Array,this.api=props.restApi,this.originalLogicalId=this.stack.getLogicalId(this),this.overrideLogicalId(core_1.Lazy.uncachedString({produce:()=>this.calculateLogicalId()}))}addToLogicalId(data){if(this.node.locked)throw new Error("Cannot modify the logical ID when the construct is locked");this.hashComponents.push(data)}calculateLogicalId(){const hash=[...this.hashComponents];if(this.api instanceof restapi_1.RestApi||this.api instanceof restapi_1.SpecRestApi){const cfnRestApiCF=this.api.node.defaultChild._toCloudFormation();hash.push(this.stack.resolve(cfnRestApiCF))}let lid=this.originalLogicalId;return hash.length>0&&(lid+=helpers_internal_1.md5hash(hash.map(x=>this.stack.resolve(x)).map(c=>JSON.stringify(c)).join(""))),lid}}