/**
 * NOTE: Extracted from AWS CDK, DO NOT MODIFY
 */ export interface ArnComponents { default readonly partition ? : string ; /**
     * The service namespace that identifies the AWS product (for example,
     * 's3', 'iam', 'codepipline').
     */ readonly service : string ; default readonly region ? : string ; default readonly account ? : string ; /**
     * Resource type (e.g. "table", "autoScalingGroup", "certificate").
     * For some resource types, e.g. S3 buckets, this field defines the bucket name.
     */ readonly resource : string ; default readonly sep ? : string ; /**
     * Resource name or path within the resource (i.e. S3 bucket object key) or
     * a wildcard such as ``"*"``. This is service-dependent.
     */ readonly resourceName ? : string ; } export class Arn { /**
     * Creates an ARN from components.
     *
     * If `partition`, `region` or `account` are not specified, the stack's
     * partition, region and account will be used.
     *
     * If any component is the empty string, an empty string will be inserted
     * into the generated ARN at the location that component corresponds to.
     *
     * The ARN will be formatted as follows:
     *
     *   arn:{partition}:{service}:{region}:{account}:{resource}{sep}{resource-name}
     *
     * The required ARN pieces that are omitted will be taken from the stack that
     * the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope
     * can be 'undefined'.
     */ static format ( components ) { const partition = components . partition ; const region = components . region ; const account = components . account ; const sep = components . sep !== undefined ? components . sep : '/' ; const values = [ 'arn' , ':' , partition , ':' , components . service , ':' , region , ':' , account , ':' , components . resource ] ; if ( sep !== '/' && sep !== ':' && sep !== '' ) { throw new Error ( 'resourcePathSep may only be ":", "/" or an empty string' ) ; } if ( components . resourceName != null ) { values . push ( sep ) ; values . push ( components . resourceName ) ; } return values . join ( '' ) ; } param arn returns static parse ( arn ) { const components = arn . split ( ':' ) ; if ( components . length < 6 ) { throw new Error ( 'ARNs must have at least 6 components: ' + arn ) ; } const [ arnPrefix , partition , service , region , account , sixth , ... rest ] = components ; if ( arnPrefix !== 'arn' ) { throw new Error ( 'ARNs must start with "arn:": ' + arn ) ; } if ( ! service ) { throw new Error ( 'The `service` component (3rd component) is required: ' + arn ) ; } if ( ! sixth ) { throw new Error ( 'The `resource` component (6th component) is required: ' + arn ) ; } let resource ; let resourceName ; let sep ; let sepIndex = sixth . indexOf ( '/' ) ; if ( sepIndex !== - 1 ) { sep = '/' ; } else if ( rest . length > 0 ) { sep = ':' ; sepIndex = - 1 ; } if ( sepIndex !== - 1 ) { resource = sixth . substr ( 0 , sepIndex ) ; resourceName = sixth . substr ( sepIndex + 1 ) ; } else { resource = sixth ; } if ( rest . length > 0 ) { if ( ! resourceName ) { resourceName = '' ; } else { resourceName += ':' ; } resourceName += rest . join ( ':' ) ; } return { service : service , resource : resource , partition : partition , region , account , resourceName , sep , } ; } private constructor ( ) { } }