import { AccountSASPermissions , AccountSASResourceTypes , AccountSASServices } from "@azure/storage-blob" ; import Operation from "../generated/artifacts/operation" ; import { AccountSASPermission } from "./AccountSASPermissions" ; import { AccountSASResourceType } from "./AccountSASResourceTypes" ; import { AccountSASService } from "./AccountSASServices" ; export class OperationAccountSASPermission { constructor ( public readonly service , public readonly resourceType , public readonly permission ) { } public validate ( services , resourceTypes , permissions ) { return ( this . validateServices ( services ) && this . validateResourceTypes ( resourceTypes ) && this . validatePermissions ( permissions ) ) ; } public validateServices ( services ) { return services . toString ( ) . includes ( this . service ) ; } public validateResourceTypes ( resourceTypes ) { for ( const p of this . resourceType ) { if ( resourceTypes . toString ( ) . includes ( p ) ) { return true ; } } return false ; } public validatePermissions ( permissions ) { for ( const p of this . permission ) { if ( permissions . toString ( ) . includes ( p ) ) { return true ; } } return false ; } } const OPERATION_ACCOUNT_SAS_PERMISSIONS = new Map < Operation , OperationAccountSASPermission > ( ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Service_GetAccountInfo , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service + AccountSASResourceType . Container + AccountSASResourceType . Object , AccountSASPermission . Read + AccountSASPermission . Create + AccountSASPermission . Delete + AccountSASPermission . List + AccountSASPermission . Process + AccountSASPermission . Read + AccountSASPermission . Update + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Service_GetAccountInfoWithHead , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service + AccountSASResourceType . Container + AccountSASResourceType . Object , AccountSASPermission . Read + AccountSASPermission . Create + AccountSASPermission . Delete + AccountSASPermission . List + AccountSASPermission . Process + AccountSASPermission . Read + AccountSASPermission . Update + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_GetAccountInfo , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service + AccountSASResourceType . Container + AccountSASResourceType . Object , AccountSASPermission . Read + AccountSASPermission . Create + AccountSASPermission . Delete + AccountSASPermission . List + AccountSASPermission . Process + AccountSASPermission . Read + AccountSASPermission . Update + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_GetAccountInfoWithHead , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service + AccountSASResourceType . Container + AccountSASResourceType . Object , AccountSASPermission . Read + AccountSASPermission . Create + AccountSASPermission . Delete + AccountSASPermission . List + AccountSASPermission . Process + AccountSASPermission . Read + AccountSASPermission . Update + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_GetAccountInfo , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service + AccountSASResourceType . Container + AccountSASResourceType . Object , AccountSASPermission . Read + AccountSASPermission . Create + AccountSASPermission . Delete + AccountSASPermission . List + AccountSASPermission . Process + AccountSASPermission . Read + AccountSASPermission . Update + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_GetAccountInfoWithHead , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service + AccountSASResourceType . Container + AccountSASResourceType . Object , AccountSASPermission . Read + AccountSASPermission . Create + AccountSASPermission . Delete + AccountSASPermission . List + AccountSASPermission . Process + AccountSASPermission . Read + AccountSASPermission . Update + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Service_ListContainersSegment , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service , AccountSASPermission . List ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Service_GetProperties , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Service_SetProperties , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Service_GetStatistics , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Service , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_Create , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Create + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_SetAccessPolicy , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , "" ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_GetAccessPolicy , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , "" ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_GetProperties , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_GetPropertiesWithHead , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_SetMetadata , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_BreakLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Write + AccountSASPermission . Delete ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_RenewLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_ChangeLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_AcquireLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_ReleaseLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_Delete , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . Delete ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_ListBlobHierarchySegment , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . List ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Container_ListBlobFlatSegment , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Container , AccountSASPermission . List ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . BlockBlob_Upload , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write + AccountSASPermission . Create ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . PageBlob_Create , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write + AccountSASPermission . Create ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . AppendBlob_Create , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write + AccountSASPermission . Create ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_Download , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_GetProperties , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_SetHTTPHeaders , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_GetProperties , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_SetMetadata , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_Delete , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Delete ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_BreakLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Delete + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_RenewLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_ChangeLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_AcquireLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_ReleaseLease , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_CreateSnapshot , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write + AccountSASPermission . Create ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_StartCopyFromURL , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write + AccountSASPermission . Create ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_CopyFromURL , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write + AccountSASPermission . Create ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . PageBlob_CopyIncremental , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write + AccountSASPermission . Create ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_AbortCopyFromURL , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . BlockBlob_StageBlock , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . BlockBlob_CommitBlockList , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . BlockBlob_GetBlockList , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . PageBlob_UploadPages , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . PageBlob_GetPageRanges , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . PageBlob_GetPageRangesDiff , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Read ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . AppendBlob_AppendBlock , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Add + AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . PageBlob_ClearPages , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . Blob_SetTier , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; OPERATION_ACCOUNT_SAS_PERMISSIONS . set ( Operation . PageBlob_UpdateSequenceNumber , new OperationAccountSASPermission ( AccountSASService . Blob , AccountSASResourceType . Object , AccountSASPermission . Write ) ) ; export default OPERATION_ACCOUNT_SAS_PERMISSIONS ;