"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReportGroup=exports.ReportGroupType=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var codebuild_generated_1=()=>{var tmp=require("./codebuild.generated");return codebuild_generated_1=()=>tmp,tmp},report_group_utils_1=()=>{var tmp=require("./report-group-utils");return report_group_utils_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp};class ReportGroupBase extends cdk().Resource{grantWrite(identity){const typeAction=this.type===ReportGroupType.CODE_COVERAGE?"codebuild:BatchPutCodeCoverages":"codebuild:BatchPutTestCases",ret=iam().Grant.addToPrincipal({grantee:identity,actions:["codebuild:CreateReport","codebuild:UpdateReport",typeAction],resourceArns:[this.reportGroupArn]});return this.exportBucket&&this.exportBucket.grantWrite(identity),ret}}var ReportGroupType;(function(ReportGroupType2){ReportGroupType2.TEST="TEST",ReportGroupType2.CODE_COVERAGE="CODE_COVERAGE"})(ReportGroupType||(exports.ReportGroupType=ReportGroupType={}));class ReportGroup extends ReportGroupBase{static fromReportGroupName(scope,id,reportGroupName){class Import extends ReportGroupBase{constructor(){super(...arguments),this.reportGroupName=reportGroupName,this.reportGroupArn=(0,report_group_utils_1().renderReportGroupArn)(scope,reportGroupName),this.exportBucket=void 0,this.type=void 0}}return new Import(scope,id)}constructor(scope,id,props={}){super(scope,id,{physicalName:props.reportGroupName});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_codebuild_ReportGroupProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ReportGroup),error}this.type=props.type?props.type:ReportGroupType.TEST;const resource=new(codebuild_generated_1()).CfnReportGroup(this,"Resource",{type:this.type,exportConfig:{exportConfigType:props.exportBucket?"S3":"NO_EXPORT",s3Destination:props.exportBucket?{bucket:props.exportBucket.bucketName,encryptionDisabled:props.exportBucket.encryptionKey?!1:void 0,encryptionKey:props.exportBucket.encryptionKey?.keyArn,packaging:props.zipExport?"ZIP":void 0}:void 0},name:props.reportGroupName,deleteReports:props.deleteReports});if(resource.applyRemovalPolicy(props.removalPolicy,{default:cdk().RemovalPolicy.RETAIN}),this.reportGroupArn=this.getResourceArnAttribute(resource.attrArn,(0,report_group_utils_1().reportGroupArnComponents)(this.physicalName)),this.reportGroupName=this.getResourceNameAttribute(cdk().Fn.select(1,cdk().Fn.split("/",resource.ref))),this.exportBucket=props.exportBucket,props.deleteReports&&props.removalPolicy!==cdk().RemovalPolicy.DESTROY)throw new Error("Cannot use 'deleteReports' property on a report group without setting removal policy to 'DESTROY'.")}}exports.ReportGroup=ReportGroup,_a=JSII_RTTI_SYMBOL_1,ReportGroup[_a]={fqn:"aws-cdk-lib.aws_codebuild.ReportGroup",version:"2.159.0"};
